Class TempFileStorageProvider

  • All Implemented Interfaces:
    StorageProvider

    public class TempFileStorageProvider
    extends AbstractStorageProvider
    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);
     
    • Constructor Detail

      • TempFileStorageProvider

        public TempFileStorageProvider()
        Equivalent to using constructor TempFileStorageProvider("m4j", null, null).
      • TempFileStorageProvider

        public TempFileStorageProvider​(File directory)
        Equivalent to using constructor TempFileStorageProvider("m4j", null, directory).
      • TempFileStorageProvider

        public TempFileStorageProvider​(String prefix,
                                       String suffix,
                                       File directory)
        Creates a new TempFileStorageProvider 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 be null to use the suffix ".tmp".
        directory - the directory in which the file is to be created, or null if the default temporary-file directory is to be used (specified by the system property java.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 not null).