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

public final Class TempFile

extends Object
Class Inheritance
Imports
java.io.File, .IOException

Interface for creating temporary files. Collects them all into one directory by default.

Field Summary

Modifier and TypeField and Description
public static final String
JAVA_IO_TMPDIR

Define a constant for this property as it is sometimes mistypes as "tempdir" otherwise

private static TempFileCreationStrategy
strategy

The strategy used by createTempFile(String, String) to create the temporary files.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static File
public static File

Returns:

The path to the newly created and empty temporary 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
)

Creates a new and empty temporary file.

public static void
setTempFileCreationStrategy(TempFileCreationStrategy
The new strategy to be used to create the temporary files.
strategy
)

Configures the strategy used by createTempFile(String, String) to create the temporary files.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JAVA_IO_TMPDIRback to summary
public static final String JAVA_IO_TMPDIR

Define a constant for this property as it is sometimes mistypes as "tempdir" otherwise

strategyback to summary
private static TempFileCreationStrategy strategy

The strategy used by createTempFile(String, String) to create the temporary files.

Constructor Detail

TempFileback to summary
private TempFile()

Method Detail

createTempDirectoryback to summary
public static File createTempDirectory(String name) throws IOException
createTempFileback to summary
public static File createTempFile(String prefix, String suffix) throws IOException

Creates a new and empty temporary file. By default, files are collected into one directory and are not deleted on exit from the VM, although they can be deleted by defining the system property poi.delete.tmp.files.on.exit (see DefaultTempFileCreationStrategy), which may cause OutOfMemoryError problem due to the frequent usage of File#deleteOnExit()

Don't forget to close all files or it might not be possible to delete them.

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.

Exceptions
IOException:
If no temporary file could be created.
setTempFileCreationStrategyback to summary
public static void setTempFileCreationStrategy(TempFileCreationStrategy strategy)

Configures the strategy used by createTempFile(String, String) to create the temporary files.

Parameters
strategy:TempFileCreationStrategy

The new strategy to be used to create the temporary files.

Exceptions
IllegalArgumentException:
When the given strategy is null.