src/share/classes/sun/applet/AppletViewer.java
Print this page
@@ -666,15 +666,15 @@
return null; // cancelled
}
String dname = fd.getDirectory();
File file = new File(dname, fname);
- try {
- BufferedOutputStream s = new BufferedOutputStream(new FileOutputStream(file));
- ObjectOutputStream os = new ObjectOutputStream(s);
- showStatus(amh.getMessage("appletsave.err1",
- panel.applet.toString(), file.toString()));
+ try (FileOutputStream fos = new FileOutputStream(file);
+ BufferedOutputStream bos = new BufferedOutputStream(fos);
+ ObjectOutputStream os = new ObjectOutputStream(bos)) {
+
+ showStatus(amh.getMessage("appletsave.err1", panel.applet.toString(), file.toString()));
os.writeObject(panel.applet);
} catch (IOException ex) {
System.err.println(amh.getMessage("appletsave.err2", ex));
} finally {
panel.sendEvent(AppletPanel.APPLET_START);