src/share/classes/sun/applet/Main.java
Print this page
@@ -430,14 +430,12 @@
dotHJ.toString()));
avProps = setDefaultAVProps();
}
// SAVE THE FILE
- try {
- FileOutputStream out = new FileOutputStream(dotAV);
+ try (FileOutputStream out = new FileOutputStream(dotAV)) {
avProps.store(out, lookup("main.prop.store"));
- out.close();
} catch (IOException e) {
System.err.println(lookup("main.err.prop.cantsave",
dotAV.toString()));
}
}
@@ -470,17 +468,14 @@
private Properties getAVProps(File inFile) {
Properties avProps = new Properties();
// read the file
Properties tmpProps = new Properties();
- try {
- FileInputStream in = new FileInputStream(inFile);
+ try (FileInputStream in = new FileInputStream(inFile)) {
tmpProps.load(new BufferedInputStream(in));
- in.close();
} catch (IOException e) {
- System.err.println(lookup("main.err.prop.cantread",
- inFile.toString()));
+ System.err.println(lookup("main.err.prop.cantread", inFile.toString()));
}
// pick off the properties we care about
for (int i = 0; i < avDefaultUserProps.length; i++) {
String value = tmpProps.getProperty(avDefaultUserProps[i][0]);