ca.ucalgary.services.util
Class TempDir
java.lang.Object
ca.ucalgary.services.util.TempDir
public class TempDir
- extends Object
Provides a facility to generate a temporary directory that can be automaticallly deleted on
program exit. Amazingly, no JDK facility to do this exists (only for files, not directories).
This code is adapted from http://forum.java.sun.com/thread.jspa?threadID=470197&messageID=2169110
posted by Jean-Francois Briere (with permission).
Method Summary |
static File |
createTempDir(String prefix,
File directory)
Creates a temp directory with a generated name (given a certain prefix) in a given directory. |
static void |
delete(File dir)
Recursively destroys a directory and its contents. |
TempDir
public TempDir()
createTempDir
public static File createTempDir(String prefix,
File directory)
throws IOException
- Creates a temp directory with a generated name (given a certain prefix) in a given directory.
The directory (and all its content) will be destroyed on exit, or when delete() is called.
If the directory passed in is null, the default temporary directory for Java will be used as
the parent directory for the newly created one.
- Throws:
IOException
delete
public static void delete(File dir)
- Recursively destroys a directory and its contents.
Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010