TempFile utility class to create temporary files.
Classes that implement a TempFileCreationStrategy attempt to handle the cleanup
of temporary files.
Examples include:
DefaultTempFileCreationStrategy deletes 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.
n most-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.
java.io.DeleteOnExitHook maintaining 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 |
|---|---|
| public File | Returns: The path to the newly created and empty temporary directory.The directory name to be used to generate the name of the temporary directory. prefix)Creates a new and empty temporary directory. |
| public File | Returns: The path to the newly created and empty temporary file.The prefix to be used to generate the name of the temporary file. prefix, String The suffix to be used to generate the name of the temporary file. suffix)Creates a new and empty temporary file. |
| createTempDirectory | back to summary |
|---|---|
| public File createTempDirectory(String prefix) throws IOException Creates a new and empty temporary directory.
| |
| createTempFile | back to summary |
|---|---|
| public File createTempFile(String prefix, String suffix) throws IOException Creates a new and empty temporary file.
| |