public interface TempFileCreationStrategy
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. 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 |
---|---|
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.
(创建一个新的空临时文件。)
|
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.
(prefix - 用于生成临时文件名称的前缀。)
suffix
- The suffix to be used to generate the name of the temporary file.
(suffix - 用于生成临时文件名称的后缀。)
java.io.IOException
- If no temporary file could be created.
(java.io.IOException - 如果无法创建临时文件。)
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.
(prefix - 用于生成临时目录名称的目录名称。)
java.io.IOException
- If no temporary directory could be created.
(java.io.IOException - 如果无法创建临时目录。)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.