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
KEEP_FILES
. 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.
(TempFile 使用的 TempFileCreationStrategy 的默认实现:文件被收集到一个目录中,默认情况下在退出 VM 时被删除。用户可以在 JVM 退出之前手动删除文件。可以通过定义系统属性 KEEP_FILES 来保存文件。每个文件都向 JVM 注册删除,并且在 JVM 退出后临时目录不会被删除。在 DefaultTempFileCreationStrategy 控制之外的 poifiles 目录中创建的文件不会被删除。有关长时间运行的进程或有限临时存储的更好策略,请参阅 TempFileCreationStrategy。)
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KEEP_FILES
To keep files after JVM exit, set the
-Dpoi.keep.tmp.files JVM property
(要在 JVM 退出后保留文件,请设置 -Dpoi.keep.tmp.files JVM 属性)
|
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 KEEP_FILES
-Dpoi.keep.tmp.files
JVM property
(要在 JVM 退出后保留文件,请设置 -Dpoi.keep.tmp.files JVM 属性)
public 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).
(dir - 将在其中创建临时文件的目录(使用默认目录为 null)。)
File.createTempFile(String, String, File)
public java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
TempFileCreationStrategy
createTempFile
in interface
TempFileCreationStrategy
(接口 TempFileCreationStrategy 中的 createTempFile)
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 - 如果无法创建临时文件。)
public java.io.File createTempDirectory(java.lang.String prefix) throws java.io.IOException
TempFileCreationStrategy
createTempDirectory
in interface
TempFileCreationStrategy
(接口 TempFileCreationStrategy 中的 createTempDirectory)
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.