Commit f5789b74 by samrobinson Committed by tonihei

Make use of try with-resources to auto close file.

PiperOrigin-RevId: 412901581
parent 83408d06
...@@ -117,22 +117,19 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -117,22 +117,19 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
throws IOException { throws IOException {
File analysisFile = File analysisFile =
createExternalCacheFile(context, /* fileName= */ result.testId + "-result.txt"); createExternalCacheFile(context, /* fileName= */ result.testId + "-result.txt");
FileWriter fileWriter = new FileWriter(analysisFile); try (FileWriter fileWriter = new FileWriter(analysisFile)) {
String fileContents = String fileContents =
"test=" "test="
+ result.testId + result.testId
+ ", deviceBrand=" + ", deviceBrand="
+ Build.MANUFACTURER + Build.MANUFACTURER
+ ", deviceModel=" + ", deviceModel="
+ Build.MODEL + Build.MODEL
+ ", sdkVersion=" + ", sdkVersion="
+ Build.VERSION.SDK_INT + Build.VERSION.SDK_INT
+ ", outputSizeBytes=" + ", outputSizeBytes="
+ result.outputSizeBytes; + result.outputSizeBytes;
try {
fileWriter.write(fileContents); fileWriter.write(fileContents);
} finally {
fileWriter.close();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment