Package org.apache.poi.util
Class TempFile
java.lang.Object
org.apache.poi.util.TempFile
Interface for creating temporary files. Collects them all into one directory by default.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Define a constant for this property as it is sometimes mistypes as "tempdir" otherwise -
Method Summary
Modifier and TypeMethodDescriptionstatic File
createTempDirectory
(String name) static File
createTempFile
(String prefix, String suffix) Creates a new and empty temporary file.static void
Configures the strategy used bycreateTempFile(String, String)
to create the temporary files.
-
Field Details
-
JAVA_IO_TMPDIR
Define a constant for this property as it is sometimes mistypes as "tempdir" otherwise- See Also:
-
-
Method Details
-
setTempFileCreationStrategy
Configures the strategy used bycreateTempFile(String, String)
to create the temporary files.- Parameters:
strategy
- The new strategy to be used to create the temporary files.- Throws:
IllegalArgumentException
- When the given strategy isnull
.
-
createTempFile
Creates a new and empty temporary file. By default, files are collected into one directory and are deleted on exit from the VM, although they can be kept by defining the system propertypoi.keep.tmp.files
(seeDefaultTempFileCreationStrategy
).Don't forget to close all files or it might not be possible to delete them.
- 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
- Throws:
IOException
-