Make use of try with-resources to auto close file.
PiperOrigin-RevId: 412901581
This commit is contained in:
parent
dd9d87549d
commit
d55f9876ac
@ -117,7 +117,7 @@ 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
|
||||||
@ -129,10 +129,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
+ Build.VERSION.SDK_INT
|
+ Build.VERSION.SDK_INT
|
||||||
+ ", outputSizeBytes="
|
+ ", outputSizeBytes="
|
||||||
+ result.outputSizeBytes;
|
+ result.outputSizeBytes;
|
||||||
try {
|
|
||||||
fileWriter.write(fileContents);
|
fileWriter.write(fileContents);
|
||||||
} finally {
|
|
||||||
fileWriter.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user