public class TempFileManager
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
cleanup()
Clear out the temporary working directory.
|
static java.io.File |
getTemporaryDirectory(java.lang.String handle)
Get a temporary working directory.
|
static java.io.File |
getTemporaryDirectory(java.lang.String handle,
java.io.File parent) |
static java.io.File |
getTemporaryFile(java.lang.String handle)
Get a temporary file, if possible, and register it for cleanup later.
|
static java.io.File |
getTemporaryFile(java.lang.String handle,
java.io.File parent) |
static void |
registerTemporaryFile(java.io.File f) |
static void |
setWorkingDirectory(java.io.File f)
Set the working temporary directory.
|
public static void setWorkingDirectory(java.io.File f)
Set the working temporary directory. This method can only be invoked when
the singleton instance is uninitialized, and the File
passed in
must be both a directory and writable.
f
- the temporary working directorypublic static java.io.File getTemporaryFile(java.lang.String handle)
Get a temporary file, if possible, and register it for cleanup later. In the event that a temporary file cannot be created, the method will attempt to create a file in the current working directory instead.
handle
- a prefix to use in naming the file; probably only useful for
debugging.public static java.io.File getTemporaryFile(java.lang.String handle, java.io.File parent)
public static java.io.File getTemporaryDirectory(java.lang.String handle)
Get a temporary working directory.
handle
- a prefix to use in naming the directory.getTemporaryFile(String)
public static java.io.File getTemporaryDirectory(java.lang.String handle, java.io.File parent)
public static void registerTemporaryFile(java.io.File f)
public static void cleanup()
Clear out the temporary working directory. This can be called by, e.g., a commandline tool or other client when it is known that all temporary files can be deleted.