Package org.apache.james.mime4j.storage
Class TempFileStorageProvider
- java.lang.Object
-
- org.apache.james.mime4j.storage.AbstractStorageProvider
-
- org.apache.james.mime4j.storage.TempFileStorageProvider
-
- All Implemented Interfaces:
StorageProvider
public class TempFileStorageProvider extends AbstractStorageProvider
AStorageProviderthat stores the data in temporary files. The files are stored either in a user-specified directory or the default temporary-file directory (specified by system propertyjava.io.tmpdir).Example usage:
File directory = new File("/tmp/mime4j"); StorageProvider provider = new TempFileStorageProvider(directory); DefaultStorageProvider.setInstance(provider);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classTempFileStorageProvider.TempFileStorageprivate static classTempFileStorageProvider.TempFileStorageOutputStream
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_PREFIXprivate java.io.Filedirectoryprivate java.lang.Stringprefixprivate java.lang.Stringsuffix
-
Constructor Summary
Constructors Constructor Description TempFileStorageProvider()Equivalent to using constructorTempFileStorageProvider("m4j", null, null).TempFileStorageProvider(java.io.File directory)Equivalent to using constructorTempFileStorageProvider("m4j", null, directory).TempFileStorageProvider(java.lang.String prefix, java.lang.String suffix, java.io.File directory)Creates a newTempFileStorageProviderusing the given values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StorageOutputStreamcreateStorageOutputStream()Creates aStorageOutputStreamwhere data to be stored can be written to.-
Methods inherited from class org.apache.james.mime4j.storage.AbstractStorageProvider
store
-
-
-
-
Field Detail
-
DEFAULT_PREFIX
private static final java.lang.String DEFAULT_PREFIX
- See Also:
- Constant Field Values
-
prefix
private final java.lang.String prefix
-
suffix
private final java.lang.String suffix
-
directory
private final java.io.File directory
-
-
Constructor Detail
-
TempFileStorageProvider
public TempFileStorageProvider()
Equivalent to using constructorTempFileStorageProvider("m4j", null, null).
-
TempFileStorageProvider
public TempFileStorageProvider(java.io.File directory)
Equivalent to using constructorTempFileStorageProvider("m4j", null, directory).
-
TempFileStorageProvider
public TempFileStorageProvider(java.lang.String prefix, java.lang.String suffix, java.io.File directory)Creates a newTempFileStorageProviderusing the given values.- Parameters:
prefix- prefix for generating the temporary file's name; must be at least three characters long.suffix- suffix for generating the temporary file's name; may benullto use the suffix".tmp".directory- the directory in which the file is to be created, ornullif the default temporary-file directory is to be used (specified by the system propertyjava.io.tmpdir).- Throws:
java.lang.IllegalArgumentException- if the given prefix is less than three characters long or the given directory does not exist and cannot be created (if it is notnull).
-
-
Method Detail
-
createStorageOutputStream
public StorageOutputStream createStorageOutputStream() throws java.io.IOException
Description copied from interface:StorageProviderCreates aStorageOutputStreamwhere data to be stored can be written to. Subsequently the user can calltoStorage()on that object to get aStorageinstance that holds the data that has been written.- Returns:
- a
StorageOutputStreamwhere data can be written to. - Throws:
java.io.IOException- if an I/O error occurs.
-
-