public class DefaultTempFileCreationStrategy extends java.lang.Object implements TempFileCreationStrategy
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 DELETE_FILES_ON_EXIT
.
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.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DELETE_FILES_ON_EXIT
To use files.deleteOnExit after clean JVM exit, set the
-Dpoi.delete.tmp.files.on.exit JVM property |
static java.lang.String |
POIFILES |
Constructor and Description |
---|
DefaultTempFileCreationStrategy()
Creates the strategy so that it creates the temporary files in the default directory.
|
DefaultTempFileCreationStrategy(java.io.File dir)
Creates the strategy allowing to set the
|
Modifier and Type | Method and Description |
---|---|
java.io.File |
createTempDirectory(java.lang.String prefix)
Creates a new and empty temporary directory.
|
java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix)
Creates a new and empty temporary file.
|
public static final java.lang.String POIFILES
public static final java.lang.String DELETE_FILES_ON_EXIT
-Dpoi.delete.tmp.files.on.exit
JVM propertypublic DefaultTempFileCreationStrategy()
File.createTempFile(String, String)
public DefaultTempFileCreationStrategy(java.io.File dir)
dir
- The directory where the temporary files will be created (null
to use the default directory).Files.createTempFile(Path, String, String, FileAttribute[])
public java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
TempFileCreationStrategy
createTempFile
in interface TempFileCreationStrategy
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.java.io.IOException
- If no temporary file could be created.public java.io.File createTempDirectory(java.lang.String prefix) throws java.io.IOException
TempFileCreationStrategy
createTempDirectory
in interface TempFileCreationStrategy
prefix
- The directory name to be used to generate the name of the temporary directory.java.io.IOException
- If no temporary directory could be created.Copyright 2022 The Apache Software Foundation or its licensors, as applicable.