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