public interface TempFileCreationStrategy
TempFileutility class to create temporary files. Classes that implement a TempFileCreationStrategy attempt to handle the cleanup of temporary files. Examples include:
DefaultTempFileCreationStrategydeletes temporary files when the JVM exits. This may not be suitable for long-running applications that never shut down the JVM since the list of registered files and disk space usage would grow for as long as the JVM is running. You may wish to implement your own strategy that meets the needs of your situation.
nmost-recent files, discarding older files on a first-in, first-out basis. A java.util.Deque or org.apache.commons.collections4.queue.CircularFifoQueue may be helpful for achieving this.
DeleteOnExitHookmaintaining the list, and the files could be deleted before the JVM exit.
createTempDirectory(String)and creating regular (unregistered) files in the temp directory.
|Modifier and Type||Method and Description|
Creates a new and empty temporary directory.
Creates a new and empty temporary file.
java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
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.
java.io.File createTempDirectory(java.lang.String prefix) throws java.io.IOException
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 2020 The Apache Software Foundation or its licensors, as applicable.