Class DefaultTempFileCreationStrategy

java.lang.Object
org.apache.poi.util.DefaultTempFileCreationStrategy
All Implemented Interfaces:
TempFileCreationStrategy
Direct Known Subclasses:
UserNameAwareTempFileCreationStrategy

public class DefaultTempFileCreationStrategy extends Object implements TempFileCreationStrategy
Default implementation of the TempFileCreationStrategy used by TempFile: Files are collected into one directory. Files may be manually deleted by user prior to JVM exit. You can define the system property DELETE_FILES_ON_EXIT if you want to delete any stray files on clean JVM exit (any non-empty value means add the deleteOnExit flag). The POI code should tidy up temp files when it no longer needs them. The temporary directory is not deleted after the JVM exits. Files that are created in the poifiles directory outside the control of DefaultTempFileCreationStrategy are not deleted. See TempFileCreationStrategy for better strategies for long-running processes or limited temporary storage.
  • Field Details

    • POIFILES

      public static final String POIFILES
      Name of POI files directory in temporary directory.
      See Also:
    • DELETE_FILES_ON_EXIT

      public static final String DELETE_FILES_ON_EXIT
      To use files.deleteOnExit after clean JVM exit, set the -Dpoi.delete.tmp.files.on.exit JVM property
      See Also:
  • Constructor Details

    • DefaultTempFileCreationStrategy

      public DefaultTempFileCreationStrategy()
      Creates the strategy so that it creates the temporary files in the default directory.
      See Also:
    • DefaultTempFileCreationStrategy

      public DefaultTempFileCreationStrategy(File dir)
      Creates the strategy allowing to set a custom directory for the temporary files.

      If you provide a non-null dir as input, it must be a directory (if it already exists). Since POI 5.5.0, this is checked at construction time. In previous versions, it was checked at the first call to createTempFile(String, String) or createTempDirectory(String).

      Parameters:
      dir - The directory where the temporary files will be created (null to use the default directory).
      Throws:
      IllegalArgumentException - if the provided directory does not exist or is not a directory
      See Also:
  • Method Details