Version: 1.1.1

ca.ucalgary.services.util
Class TempDir

java.lang.Object
  extended by 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).


Constructor Summary
TempDir()
           
 
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TempDir

public TempDir()
Method Detail

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.


Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010