KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openedit > repository > filesystem > DirectoryTool


1 /*
2  * Created on Dec 23, 2004
3  */

4 package org.openedit.repository.filesystem;
5
6 import java.io.File JavaDoc;
7
8 import com.openedit.util.FileUtils;
9
10 /**
11  * @author Matthew Avery, mavery@einnovation.com
12  */

13 public class DirectoryTool
14 {
15     protected File JavaDoc fieldRootDirectory;
16     protected FileUtils fieldFileUtils = new FileUtils();
17
18     public File JavaDoc getRootDirectory()
19     {
20         if ( fieldRootDirectory == null )
21         {
22             String JavaDoc tempDir = System.getProperty( "java.io.tmpdir" );
23             fieldRootDirectory = new File JavaDoc( tempDir, "oe_version_test" ); //use the same one each time
24
getFileUtils().deleteAll( fieldRootDirectory );
25             fieldRootDirectory.mkdir();
26         }
27         return fieldRootDirectory;
28     }
29     
30     public FileUtils getFileUtils()
31     {
32         return fieldFileUtils;
33     }
34     /* (non-Javadoc)
35      * @see junit.framework.TestCase#tearDown()
36      */

37     public void tearDown() throws Exception JavaDoc
38     {
39         getFileUtils().deleteAll( getRootDirectory() );
40     }
41 }
42
Popular Tags