use try-with-resources

This commit is contained in:
Unpublished
2019-02-22 16:59:23 +01:00
parent 72dcc50ea1
commit 0edc7a8629
16 changed files with 117 additions and 316 deletions

View File

@@ -129,21 +129,11 @@ public class ApplicationEx extends Application {
File file = new File(context.getCacheDir(), "crash.log");
Log.w("Writing exception to " + file);
FileWriter out = null;
try {
out = new FileWriter(file, true);
try (FileWriter out = new FileWriter(file, true)) {
out.write(BuildConfig.VERSION_NAME + " " + new Date() + "\r\n");
out.write(ex + "\r\n" + android.util.Log.getStackTraceString(ex) + "\r\n");
} catch (IOException e) {
Log.e(e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
Log.e(e);
}
}
}
}
}