Top Description Fields Constructors Methods
org.apache.poi.util

public Class DefaultTempFileCreationStrategy

extends Object
implements TempFileCreationStrategy
Class Inheritance
All Implemented Interfaces
org.apache.poi.util.TempFileCreationStrategy
Static Imports
org.apache.poi.util.TempFile.JAVA_IO_TMPDIR

Default implementation of the 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.

Field Summary

Modifier and TypeField and Description
public static final String
DELETE_FILES_ON_EXIT

To use files.deleteOnExit after clean JVM exit, set the -Dpoi.delete.tmp.files.on.exit JVM property

private volatile File
dir

The directory where the temporary files will be created (null to use the default directory).

private final Lock
dirLock

The lock to make dir initialized only once.

public static final String
POIFILES

Name of POI files directory in temporary directory.

Constructor Summary

AccessConstructor and Description
public
DefaultTempFileCreationStrategy()

Creates the strategy so that it creates the temporary files in the default directory.

public
DefaultTempFileCreationStrategy(File
The directory where the temporary files will be created (null to use the default directory).
dir
)

Creates the strategy allowing to set the

Method Summary

Modifier and TypeMethod and Description
private void
public File
createTempDirectory(String
The directory name to be used to generate the name of the temporary directory.
prefix
)

Implements org.apache.poi.util.TempFileCreationStrategy.createTempDirectory.

Creates a new and empty temporary directory.

public File
createTempFile(String
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
)

Implements org.apache.poi.util.TempFileCreationStrategy.createTempFile.

Creates a new and empty temporary file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DELETE_FILES_ON_EXITback to summary
public static final String DELETE_FILES_ON_EXIT

To use files.deleteOnExit after clean JVM exit, set the -Dpoi.delete.tmp.files.on.exit JVM property

dirback to summary
private volatile File dir

The directory where the temporary files will be created (null to use the default directory).

dirLockback to summary
private final Lock dirLock

The lock to make dir initialized only once.

POIFILESback to summary
public static final String POIFILES

Name of POI files directory in temporary directory.

Constructor Detail

DefaultTempFileCreationStrategyback to summary
public DefaultTempFileCreationStrategy()

Creates the strategy so that it creates the temporary files in the default directory.

See Also
File#createTempFile(String, String)
DefaultTempFileCreationStrategyback to summary
public DefaultTempFileCreationStrategy(File dir)

Creates the strategy allowing to set the

Parameters
dir:File

The directory where the temporary files will be created (null to use the default directory).

See Also
Files#createTempFile(Path, String, String, FileAttribute[])

Method Detail

createPOIFilesDirectoryback to summary
private void createPOIFilesDirectory() throws IOException
createTempDirectoryback to summary
public File createTempDirectory(String prefix) throws IOException

Implements org.apache.poi.util.TempFileCreationStrategy.createTempDirectory.

Doc from org.apache.poi.util.TempFileCreationStrategy.createTempDirectory.

Creates a new and empty temporary directory.

Parameters
prefix:String

The directory name to be used to generate the name of the temporary directory.

Returns:File

The path to the newly created and empty temporary directory.

Annotations
@Override
Exceptions
IOException:
If no temporary directory could be created.
createTempFileback to summary
public File createTempFile(String prefix, String suffix) throws IOException

Implements org.apache.poi.util.TempFileCreationStrategy.createTempFile.

Doc from org.apache.poi.util.TempFileCreationStrategy.createTempFile.

Creates a new and empty temporary file.

Parameters
prefix:String

The prefix to be used to generate the name of the temporary file.

suffix:String

The suffix to be used to generate the name of the temporary file.

Returns:File

The path to the newly created and empty temporary file.

Annotations
@Override
Exceptions
IOException:
If no temporary file could be created.