8274809: Update java.base classes to use try-with-resources

Reviewed-by: mullan, alanb, dfuchs
This commit is contained in:
Andrey Turbanov 2022-01-10 16:20:58 +00:00 committed by Daniel Fuchs
parent debaa28e9c
commit dee447f8ae
7 changed files with 20 additions and 58 deletions

View file

@ -382,9 +382,7 @@ public class MimeTable implements FileNameMap {
}
protected boolean saveAsProperties(File file) {
FileOutputStream os = null;
try {
os = new FileOutputStream(file);
try (FileOutputStream os = new FileOutputStream(file)) {
Properties properties = getAsProperties();
properties.put("temp.file.template", tempFileTemplate);
String tag;
@ -407,11 +405,6 @@ public class MimeTable implements FileNameMap {
e.printStackTrace();
return false;
}
finally {
if (os != null) {
try { os.close(); } catch (IOException e) {}
}
}
return true;
}