Package org.apache.poi.util
Class DefaultTempFileCreationStrategy
java.lang.Object
org.apache.poi.util.DefaultTempFileCreationStrategy
- All Implemented Interfaces:
TempFileCreationStrategy
Default implementation of the
TempFileCreationStrategy
used by TempFile
:
Files are collected into one directory and by default are deleted on exit from the VM.
Files may be manually deleted by user prior to JVM exit.
Files can be kept by defining the system property KEEP_FILES
.
Each file is registered for deletion with the JVM and 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final String
To keep files after JVM exit, set the-Dpoi.keep.tmp.files
JVM property -
Constructor Summary
ConstructorsConstructorDescriptionCreates the strategy so that it creates the temporary files in the default directory.Creates the strategy allowing to set the -
Method Summary
Modifier and TypeMethodDescriptioncreateTempDirectory
(String prefix) Creates a new and empty temporary directory.createTempFile
(String prefix, String suffix) Creates a new and empty temporary file.
-
Field Details
-
KEEP_FILES
To keep files after JVM exit, set the-Dpoi.keep.tmp.files
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
Creates the strategy allowing to set the- Parameters:
dir
- The directory where the temporary files will be created (null
to use the default directory).- See Also:
-
-
Method Details
-
createTempFile
Description copied from interface:TempFileCreationStrategy
Creates a new and empty temporary file.- Specified by:
createTempFile
in interfaceTempFileCreationStrategy
- Parameters:
prefix
- The prefix to be used to generate the name of the temporary file.suffix
- The suffix to be used to generate the name of the temporary file.- Returns:
- The path to the newly created and empty temporary file.
- Throws:
IOException
- If no temporary file could be created.
-
createTempDirectory
Description copied from interface:TempFileCreationStrategy
Creates a new and empty temporary directory.- Specified by:
createTempDirectory
in interfaceTempFileCreationStrategy
- Parameters:
prefix
- The directory name to be used to generate the name of the temporary directory.- Returns:
- The path to the newly created and empty temporary directory.
- Throws:
IOException
- If no temporary directory could be created.
-