01: package org.apache.velocity.texen.util;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import java.io.File;
23:
24: /**
25: * A general file utility for use in the context
26: *
27: * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
28: * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
29: * @version $Id: FileUtil.java 463298 2006-10-12 16:10:32Z henning $
30: */
31: public class FileUtil {
32: /**
33: * Creates the directory s (and any parent directories needed).
34: *
35: * @param s path/directory to create.
36: * @return report of path/directory creation.
37: */
38: static public String mkdir(String s) {
39: try {
40: if ((new File(s)).mkdirs())
41: return "Created dir: " + s;
42: else
43: return "Failed to create dir or dir already exists: "
44: + s;
45: } catch (Exception e) {
46: return e.toString();
47: }
48: }
49:
50: /**
51: * A method to get a File object.
52: *
53: * @param s path to file object to create.
54: * @return File created file object.
55: */
56: public static File file(String s) {
57: File f = new File(s);
58: return f;
59: }
60:
61: /**
62: * A method to get a File object.
63: *
64: * @param base base path
65: * @param s file name
66: * @return File created file object.
67: */
68: public static File file(String base, String s) {
69: File f = new File(base, s);
70: return f;
71: }
72: }
|