1
22
23 package com.liferay.portal.kernel.util;
24
25 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
26
27 import java.io.File;
28 import java.io.FileInputStream;
29 import java.io.IOException;
30 import java.io.InputStream;
31 import java.io.Reader;
32
33 import java.util.List;
34 import java.util.Properties;
35
36
43 public class FileUtil {
44
45 public static void copyDirectory(
46 String sourceDirName, String destinationDirName) {
47
48 getFile().copyDirectory(sourceDirName, destinationDirName);
49 }
50
51 public static void copyDirectory(File source, File destination) {
52 getFile().copyDirectory(source, destination);
53 }
54
55 public static void copyFile(String source, String destination) {
56 getFile().copyFile(source, destination);
57 }
58
59 public static void copyFile(
60 String source, String destination, boolean lazy) {
61
62 getFile().copyFile(source, destination, lazy);
63 }
64
65 public static void copyFile(File source, File destination) {
66 getFile().copyFile(source, destination);
67 }
68
69 public static void copyFile(File source, File destination, boolean lazy) {
70 getFile().copyFile(source, destination, lazy);
71 }
72
73 public static File createTempFile() {
74 return getFile().createTempFile();
75 }
76
77 public static File createTempFile(String extension) {
78 return getFile().createTempFile(extension);
79 }
80
81 public static boolean delete(String file) {
82 return getFile().delete(file);
83 }
84
85 public static boolean delete(File file) {
86 return getFile().delete(file);
87 }
88
89 public static void deltree(String directory) {
90 getFile().deltree(directory);
91 }
92
93 public static void deltree(File directory) {
94 getFile().deltree(directory);
95 }
96
97 public static boolean exists(String fileName) {
98 return getFile().exists(fileName);
99 }
100
101 public static boolean exists(File file) {
102 return getFile().exists(file);
103 }
104
105 public static String extractText(InputStream is, String fileExt) {
106 return getFile().extractText(is, fileExt);
107 }
108
109 public static String getAbsolutePath(File file) {
110 return getFile().getAbsolutePath(file);
111 }
112
113 public static byte[] getBytes(File file) throws IOException {
114 return getFile().getBytes(file);
115 }
116
117 public static byte[] getBytes(InputStream is) throws IOException {
118 return getFile().getBytes(is);
119 }
120
121 public static byte[] getBytes(InputStream is, int bufferSize)
122 throws IOException {
123
124 return getFile().getBytes(is);
125 }
126
127 public static String getExtension(String fileName) {
128 return getFile().getExtension(fileName);
129 }
130
131 public static com.liferay.portal.kernel.util.File getFile() {
132 return _getUtil()._file;
133 }
134
135 public static String getPath(String fullFileName) {
136 return getFile().getPath(fullFileName);
137 }
138
139 public static String getShortFileName(String fullFileName) {
140 return getFile().getShortFileName(fullFileName);
141 }
142
143 public static boolean isAscii(File file) throws IOException {
144 return getFile().isAscii(file);
145 }
146
147 public static String[] listDirs(String fileName) {
148 return getFile().listDirs(fileName);
149 }
150
151 public static String[] listDirs(File file) {
152 return getFile().listDirs(file);
153 }
154
155 public static String[] listFiles(String fileName) {
156 return getFile().listFiles(fileName);
157 }
158
159 public static String[] listFiles(File file) {
160 return getFile().listFiles(file);
161 }
162
163 public static void mkdirs(String pathName) {
164 getFile().mkdirs(pathName);
165 }
166
167 public static boolean move(
168 String sourceFileName, String destinationFileName) {
169
170 return getFile().move(sourceFileName, destinationFileName);
171 }
172
173 public static boolean move(File source, File destination) {
174 return getFile().move(source, destination);
175 }
176
177 public static String read(String fileName) throws IOException {
178 return getFile().read(fileName);
179 }
180
181 public static String read(File file) throws IOException {
182 return getFile().read(file);
183 }
184
185 public static String read(File file, boolean raw) throws IOException {
186 return getFile().read(file, raw);
187 }
188
189 public static String replaceSeparator(String fileName) {
190 return getFile().replaceSeparator(fileName);
191 }
192
193 public static File[] sortFiles(File[] files) {
194 return getFile().sortFiles(files);
195 }
196
197 public static String stripExtension(String fileName) {
198 return getFile().stripExtension(fileName);
199 }
200
201 public static List<String> toList(Reader reader) {
202 return getFile().toList(reader);
203 }
204
205 public static List<String> toList(String fileName) {
206 return getFile().toList(fileName);
207 }
208
209 public static Properties toProperties(FileInputStream fis) {
210 return getFile().toProperties(fis);
211 }
212
213 public static Properties toProperties(String fileName) {
214 return getFile().toProperties(fileName);
215 }
216
217 public static void write(String fileName, String s) throws IOException {
218 getFile().write(fileName, s);
219 }
220
221 public static void write(String fileName, String s, boolean lazy)
222 throws IOException {
223
224 getFile().write(fileName, s, lazy);
225 }
226
227 public static void write(
228 String fileName, String s, boolean lazy, boolean append)
229 throws IOException {
230
231 getFile().write(fileName, s, lazy, append);
232 }
233
234 public static void write(String pathName, String fileName, String s)
235 throws IOException {
236
237 getFile().write(pathName, fileName, s);
238 }
239
240 public static void write(
241 String pathName, String fileName, String s, boolean lazy)
242 throws IOException {
243
244 getFile().write(pathName, fileName, s, lazy);
245 }
246
247 public static void write(
248 String pathName, String fileName, String s, boolean lazy,
249 boolean append)
250 throws IOException {
251
252 getFile().write(pathName, fileName, s, lazy, append);
253 }
254
255 public static void write(File file, String s) throws IOException {
256 getFile().write(file, s);
257 }
258
259 public static void write(File file, String s, boolean lazy)
260 throws IOException {
261
262 getFile().write(file, s, lazy);
263 }
264
265 public static void write(File file, String s, boolean lazy, boolean append)
266 throws IOException {
267
268 getFile().write(file, s, lazy, append);
269 }
270
271 public static void write(String fileName, byte[] bytes) throws IOException {
272 getFile().write(fileName, bytes);
273 }
274
275 public static void write(File file, byte[] bytes) throws IOException {
276 getFile().write(file, bytes);
277 }
278
279 public static void write(String fileName, InputStream is)
280 throws IOException {
281
282 getFile().write(fileName, is);
283 }
284
285 public static void write(File file, InputStream is) throws IOException {
286 getFile().write(file, is);
287 }
288
289 public void setFile(com.liferay.portal.kernel.util.File file) {
290 _file = file;
291 }
292
293 private static FileUtil _getUtil() {
294 if (_util == null) {
295 _util = (FileUtil)PortalBeanLocatorUtil.locate(_UTIL);
296 }
297
298 return _util;
299 }
300
301 private static final String _UTIL = FileUtil.class.getName();
302
303 private static FileUtil _util;
304
305 private com.liferay.portal.kernel.util.File _file;
306
307 }