1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.kernel.util;
21  
22  import java.io.File;
23  import java.io.FileInputStream;
24  import java.io.IOException;
25  import java.io.InputStream;
26  import java.io.Reader;
27  
28  import java.util.List;
29  import java.util.Properties;
30  
31  /**
32   * <a href="FileUtil.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   * @author Alexander Chow
36   *
37   */
38  public class FileUtil {
39  
40      public static void copyDirectory(
41          String sourceDirName, String destinationDirName) {
42  
43          getFile().copyDirectory(sourceDirName, destinationDirName);
44      }
45  
46      public static void copyDirectory(File source, File destination) {
47          getFile().copyDirectory(source, destination);
48      }
49  
50      public static void copyFile(String source, String destination) {
51          getFile().copyFile(source, destination);
52      }
53  
54      public static void copyFile(
55          String source, String destination, boolean lazy) {
56  
57          getFile().copyFile(source, destination, lazy);
58      }
59  
60      public static void copyFile(File source, File destination) {
61          getFile().copyFile(source, destination);
62      }
63  
64      public static void copyFile(File source, File destination, boolean lazy) {
65          getFile().copyFile(source, destination, lazy);
66      }
67  
68      public static File createTempFile() {
69          return getFile().createTempFile();
70      }
71  
72      public static File createTempFile(String extension) {
73          return getFile().createTempFile(extension);
74      }
75  
76      public static boolean delete(String file) {
77          return getFile().delete(file);
78      }
79  
80      public static boolean delete(File file) {
81          return getFile().delete(file);
82      }
83  
84      public static void deltree(String directory) {
85          getFile().deltree(directory);
86      }
87  
88      public static void deltree(File directory) {
89          getFile().deltree(directory);
90      }
91  
92      public static boolean exists(String fileName) {
93          return getFile().exists(fileName);
94      }
95  
96      public static boolean exists(File file) {
97          return getFile().exists(file);
98      }
99  
100     public static String extractText(InputStream is, String fileExt) {
101         return getFile().extractText(is, fileExt);
102     }
103 
104     public static String getAbsolutePath(File file) {
105         return getFile().getAbsolutePath(file);
106     }
107 
108     public static byte[] getBytes(File file) throws IOException {
109         return getFile().getBytes(file);
110     }
111 
112     public static byte[] getBytes(InputStream is) throws IOException {
113         return getFile().getBytes(is);
114     }
115 
116     public static byte[] getBytes(InputStream is, int bufferSize)
117         throws IOException {
118 
119         return getFile().getBytes(is);
120     }
121 
122     public static String getExtension(String fileName) {
123         return getFile().getExtension(fileName);
124     }
125 
126     public static com.liferay.portal.kernel.util.File getFile() {
127         return _file;
128     }
129 
130     public static String getPath(String fullFileName) {
131         return getFile().getPath(fullFileName);
132     }
133 
134     public static String getShortFileName(String fullFileName) {
135         return getFile().getShortFileName(fullFileName);
136     }
137 
138     public static boolean isAscii(File file) throws IOException {
139         return getFile().isAscii(file);
140     }
141 
142     public static String[] listDirs(String fileName) {
143         return getFile().listDirs(fileName);
144     }
145 
146     public static String[] listDirs(File file) {
147         return getFile().listDirs(file);
148     }
149 
150     public static String[] listFiles(String fileName) {
151         return getFile().listFiles(fileName);
152     }
153 
154     public static String[] listFiles(File file) {
155         return getFile().listFiles(file);
156     }
157 
158     public static void mkdirs(String pathName) {
159         getFile().mkdirs(pathName);
160     }
161 
162     public static boolean move(
163         String sourceFileName, String destinationFileName) {
164 
165         return getFile().move(sourceFileName, destinationFileName);
166     }
167 
168     public static boolean move(File source, File destination) {
169         return getFile().move(source, destination);
170     }
171 
172     public static String read(String fileName) throws IOException {
173         return getFile().read(fileName);
174     }
175 
176     public static String read(File file) throws IOException {
177         return getFile().read(file);
178     }
179 
180     public static String read(File file, boolean raw) throws IOException {
181         return getFile().read(file, raw);
182     }
183 
184     public static String replaceSeparator(String fileName) {
185         return getFile().replaceSeparator(fileName);
186     }
187 
188     public static File[] sortFiles(File[] files) {
189         return getFile().sortFiles(files);
190     }
191 
192     public static String stripExtension(String fileName) {
193         return getFile().stripExtension(fileName);
194     }
195 
196     public static List<String> toList(Reader reader) {
197         return getFile().toList(reader);
198     }
199 
200     public static List<String> toList(String fileName) {
201         return getFile().toList(fileName);
202     }
203 
204     public static Properties toProperties(FileInputStream fis) {
205         return getFile().toProperties(fis);
206     }
207 
208     public static Properties toProperties(String fileName) {
209         return getFile().toProperties(fileName);
210     }
211 
212     public static void write(String fileName, String s) throws IOException {
213         getFile().write(fileName, s);
214     }
215 
216     public static void write(String fileName, String s, boolean lazy)
217         throws IOException {
218 
219         getFile().write(fileName, s, lazy);
220     }
221 
222     public static void write(
223             String fileName, String s, boolean lazy, boolean append)
224         throws IOException {
225 
226         getFile().write(fileName, s, lazy, append);
227     }
228 
229     public static void write(String pathName, String fileName, String s)
230         throws IOException {
231 
232         getFile().write(pathName, fileName, s);
233     }
234 
235     public static void write(
236             String pathName, String fileName, String s, boolean lazy)
237         throws IOException {
238 
239         getFile().write(pathName, fileName, s, lazy);
240     }
241 
242     public static void write(
243             String pathName, String fileName, String s, boolean lazy,
244             boolean append)
245         throws IOException {
246 
247         getFile().write(pathName, fileName, s, lazy, append);
248     }
249 
250     public static void write(File file, String s) throws IOException {
251         getFile().write(file, s);
252     }
253 
254     public static void write(File file, String s, boolean lazy)
255         throws IOException {
256 
257         getFile().write(file, s, lazy);
258     }
259 
260     public static void write(File file, String s, boolean lazy, boolean append)
261         throws IOException {
262 
263         getFile().write(file, s, lazy, append);
264     }
265 
266     public static void write(String fileName, byte[] bytes) throws IOException {
267         getFile().write(fileName, bytes);
268     }
269 
270     public static void write(File file, byte[] bytes) throws IOException {
271         getFile().write(file, bytes);
272     }
273 
274     public static void write(String fileName, InputStream is)
275         throws IOException {
276 
277         getFile().write(fileName, is);
278     }
279 
280     public static void write(File file, InputStream is) throws IOException {
281         getFile().write(file, is);
282     }
283 
284     public void setFile(com.liferay.portal.kernel.util.File file) {
285         _file = file;
286     }
287 
288     private static com.liferay.portal.kernel.util.File _file;
289 
290 }