Avoid using java.nio since it breaks Quest Mode in Android app

This commit is contained in:
drdev
2015-05-04 23:48:54 +00:00
parent d15536ae4b
commit 2e1d4de1cd
2 changed files with 30 additions and 6 deletions

View File

@@ -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);
}