mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8274809: Update java.base classes to use try-with-resources
Reviewed-by: mullan, alanb, dfuchs
This commit is contained in:
parent
debaa28e9c
commit
dee447f8ae
7 changed files with 20 additions and 58 deletions
|
@ -68,10 +68,10 @@ public class NetProperties {
|
|||
File f = new File(fname, "conf");
|
||||
f = new File(f, "net.properties");
|
||||
fname = f.getCanonicalPath();
|
||||
InputStream in = new FileInputStream(fname);
|
||||
BufferedInputStream bin = new BufferedInputStream(in);
|
||||
props.load(bin);
|
||||
bin.close();
|
||||
try (FileInputStream in = new FileInputStream(fname);
|
||||
BufferedInputStream bin = new BufferedInputStream(in)) {
|
||||
props.load(bin);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Do nothing. We couldn't find or access the file
|
||||
// so we won't have default properties...
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue