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
A
StorageProvider
that 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 property java.io.tmpdir
).
Example usage:
File directory = new File("/tmp/mime4j"); StorageProvider provider = new TempFileStorageProvider(directory); DefaultStorageProvider.setInstance(provider);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEquivalent to using constructorTempFileStorageProvider("m4j", null, null)
.TempFileStorageProvider
(File directory) Equivalent to using constructorTempFileStorageProvider("m4j", null, directory)
.TempFileStorageProvider
(String prefix, String suffix, File directory) Creates a newTempFileStorageProvider
using the given values. -
Method Summary
Modifier and TypeMethodDescriptionCreates aStorageOutputStream
where data to be stored can be written to.Methods inherited from class org.apache.james.mime4j.storage.AbstractStorageProvider
store
-
Field Details
-
DEFAULT_PREFIX
- See Also:
-
prefix
-
suffix
-
directory
-
-
Constructor Details
-
TempFileStorageProvider
public TempFileStorageProvider()Equivalent to using constructorTempFileStorageProvider("m4j", null, null)
. -
TempFileStorageProvider
Equivalent to using constructorTempFileStorageProvider("m4j", null, directory)
. -
TempFileStorageProvider
Creates a newTempFileStorageProvider
using 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 benull
to use the suffix".tmp"
.directory
- the directory in which the file is to be created, ornull
if the default temporary-file directory is to be used (specified by the system propertyjava.io.tmpdir
).- Throws:
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 Details
-
createStorageOutputStream
Description copied from interface:StorageProvider
Creates aStorageOutputStream
where data to be stored can be written to. Subsequently the user can calltoStorage()
on that object to get aStorage
instance that holds the data that has been written.- Returns:
- a
StorageOutputStream
where data can be written to. - Throws:
IOException
- if an I/O error occurs.
-