|
|
|
|
@ -146,13 +146,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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -173,7 +174,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(); |
|
|
|
|
@ -182,13 +183,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); |
|
|
|
|
@ -209,4 +203,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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|