KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > velocity > texen > util > FileUtil


1 package org.apache.velocity.texen.util;
2
3 /*
4  * Copyright 2001,2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.io.File JavaDoc;
20
21 /**
22  * A general file utility for use in the context
23  *
24  * @author <a HREF="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
25  * @author <a HREF="mailto:jvanzyl@apache.org">Jason van Zyl</a>
26  * @version $Id: FileUtil.java,v 1.9.8.1 2004/03/03 23:23:07 geirm Exp $
27  */

28 public class FileUtil
29 {
30     /**
31      * Creates the directory s (and any parent directories needed).
32      *
33      * @param String path/directory to create.
34      * @param String report of path/directory creation.
35      */

36     static public String JavaDoc mkdir (String JavaDoc s)
37     {
38         try
39         {
40             if ((new File JavaDoc(s)).mkdirs())
41                 return "Created dir: "+s;
42             else
43                 return "Failed to create dir or dir already exists: "+s;
44         }
45         catch (Exception JavaDoc e)
46         {
47             return e.toString();
48         }
49     }
50
51     /**
52      * A method to get a File object.
53      *
54      * @param String path to file object to create.
55      * @return File created file object.
56      */

57     public static File JavaDoc file(String JavaDoc s)
58     {
59         File JavaDoc f = new File JavaDoc(s);
60         return f;
61     }
62     
63     /**
64      * A method to get a File object.
65      *
66      * @param String base path
67      * @param String file name
68      * @return File created file object.
69      */

70     public static File JavaDoc file(String JavaDoc base, String JavaDoc s)
71     {
72         File JavaDoc f = new File JavaDoc(base, s);
73         return f;
74     }
75 }
76
Popular Tags