mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Avoid using java.nio since it breaks Quest Mode in Android app
This commit is contained in:
@@ -98,6 +98,35 @@ public final class FileUtil {
|
||||
return dir.delete();
|
||||
}
|
||||
|
||||
public static void copyFile(String sourceFilename, String destFilename) {
|
||||
File source = new File(sourceFilename);
|
||||
if (!source.exists()) { return; } //if source doesn't exist, nothing to copy
|
||||
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
is = new FileInputStream(source);
|
||||
os = new FileOutputStream(new File(destFilename));
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = is.read(buffer)) > 0) {
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
is.close();
|
||||
os.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeFile(String filename, String text) {
|
||||
FileUtil.writeFile(new File(filename), text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user