Commit f5789b74 by samrobinson Committed by tonihei

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

PiperOrigin-RevId: 412901581
parent 83408d06
......@@ -117,7 +117,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
throws IOException {
File analysisFile =
createExternalCacheFile(context, /* fileName= */ result.testId + "-result.txt");
FileWriter fileWriter = new FileWriter(analysisFile);
try (FileWriter fileWriter = new FileWriter(analysisFile)) {
String fileContents =
"test="
+ result.testId
......@@ -129,10 +129,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
+ Build.VERSION.SDK_INT
+ ", outputSizeBytes="
+ result.outputSizeBytes;
try {
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