• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one   *
3  * or more contributor license agreements.  See the NOTICE file *
4  * distributed with this work for additional information        *
5  * regarding copyright ownership.  The ASF licenses this file   *
6  * to you under the Apache License, Version 2.0 (the            *
7  * "License"); you may not use this file except in compliance   *
8  * with the License.  You may obtain a copy of the License at   *
9  *                                                              *
10  *   http://www.apache.org/licenses/LICENSE-2.0                 *
11  *                                                              *
12  * Unless required by applicable law or agreed to in writing,   *
13  * software distributed under the License is distributed on an  *
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15  * KIND, either express or implied.  See the License for the    *
16  * specific language governing permissions and limitations      *
17  * under the License.                                           *
18  ****************************************************************/
19 
20 package org.apache.james.mime4j.util;
21 
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.io.OutputStream;
25 
26 /**
27  * @version $Id: TempFile.java,v 1.3 2004/10/02 12:41:11 ntherning Exp $
28  */
29 public interface TempFile {
30     /**
31      * Gets an <code>InputStream</code> to read bytes from this temporary file.
32      * NOTE: The stream should NOT be wrapped in
33      * <code>BufferedInputStream</code> by the caller. If the implementing
34      * <code>TempFile</code> creates a <code>FileInputStream</code> or any
35      * other stream which would benefit from being buffered it's the
36      * <code>TempFile</code>'s responsibility to wrap it.
37      *
38      * @return the stream.
39      * @throws IOException
40      */
getInputStream()41     InputStream getInputStream() throws IOException;
42 
43     /**
44      * Gets an <code>OutputStream</code> to write bytes to this temporary file.
45      * NOTE: The stream should NOT be wrapped in
46      * <code>BufferedOutputStream</code> by the caller. If the implementing
47      * <code>TempFile</code> creates a <code>FileOutputStream</code> or any
48      * other stream which would benefit from being buffered it's the
49      * <code>TempFile</code>'s responsibility to wrap it.
50      *
51      * @return the stream.
52      * @throws IOException
53      */
getOutputStream()54     OutputStream getOutputStream() throws IOException;
55 
56     /**
57      * Returns the absolute path including file name of this
58      * <code>TempFile</code>. The path may be <code>null</code> if this is
59      * an in-memory file.
60      *
61      * @return the absolute path.
62      */
getAbsolutePath()63     String getAbsolutePath();
64 
65     /**
66      * Deletes this file as soon as possible.
67      */
delete()68     void delete();
69 
70     /**
71      * Determines if this is an in-memory file.
72      *
73      * @return <code>true</code> if this file is currently in memory,
74      *         <code>false</code> otherwise.
75      */
isInMemory()76     boolean isInMemory();
77 
78     /**
79      * Gets the length of this temporary file.
80      *
81      * @return the length.
82      */
length()83     long length();
84 }
85