|
|
|
|
@ -144,13 +144,14 @@ public class Path { |
|
|
|
|
|
|
|
|
|
public static File write(File file, byte[] data) { |
|
|
|
|
try { |
|
|
|
|
FileOutputStream fos = new FileOutputStream(file); |
|
|
|
|
FileOutputStream fos = new FileOutputStream(create(file)); |
|
|
|
|
fos.write(data); |
|
|
|
|
fos.flush(); |
|
|
|
|
fos.close(); |
|
|
|
|
chmod(file); |
|
|
|
|
return file; |
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
ignored.printStackTrace(); |
|
|
|
|
return file; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -171,7 +172,7 @@ public class Path { |
|
|
|
|
try { |
|
|
|
|
int read; |
|
|
|
|
byte[] buffer = new byte[8192]; |
|
|
|
|
FileOutputStream fos = new FileOutputStream(out); |
|
|
|
|
FileOutputStream fos = new FileOutputStream(create(out)); |
|
|
|
|
while ((read = in.read(buffer)) != -1) fos.write(buffer, 0, read); |
|
|
|
|
fos.close(); |
|
|
|
|
in.close(); |
|
|
|
|
@ -180,13 +181,6 @@ public class Path { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void newFile(File file) { |
|
|
|
|
try { |
|
|
|
|
file.createNewFile(); |
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static List<File> list(File dir) { |
|
|
|
|
File[] files = dir.listFiles(); |
|
|
|
|
return files == null ? Collections.emptyList() : Arrays.asList(files); |
|
|
|
|
@ -207,4 +201,15 @@ public class Path { |
|
|
|
|
return file; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static File create(File file) throws Exception { |
|
|
|
|
try { |
|
|
|
|
if (!file.exists()) file.createNewFile(); |
|
|
|
|
if (!file.canWrite()) file.setWritable(true); |
|
|
|
|
return file; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return file; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|