diff options
author | Andrew Su <[email protected]> | 2011-03-08 10:11:28 -0500 |
---|---|---|
committer | Andrew Su <[email protected]> | 2011-03-08 10:11:28 -0500 |
commit | 261b0560100e15e376cb6bcf64eaabb5a79b24c5 (patch) | |
tree | d20174223b4de5a09e076f739596f040e7da00b7 | |
parent | 847e7b1b2f78e27693d33281bcce54801a7a9ce7 (diff) |
Close streams after opening them.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/PropertiesFile.java | 24 |
2 files changed, 22 insertions, 8 deletions
@@ -1,3 +1,9 @@ +2011-03-08 Andrew Su <[email protected]> + + * netx/net/sourceforge/jnlp/util/PropertiesFile.java: + (load): Closed streams after opening them. + (store): Likewise. + 2011-03-08 Denis Lila <[email protected]> * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java diff --git a/netx/net/sourceforge/jnlp/util/PropertiesFile.java b/netx/net/sourceforge/jnlp/util/PropertiesFile.java index 32006b6..a3188e0 100644 --- a/netx/net/sourceforge/jnlp/util/PropertiesFile.java +++ b/netx/net/sourceforge/jnlp/util/PropertiesFile.java @@ -25,8 +25,6 @@ import java.util.*; * file when the first property is requested, but the save method * must be called before changes are saved to the file.<p> * - * This class does not report IO exceptions.<p> - * * @author <a href="mailto:[email protected]">Jon A. Maxwell (JAM)</a> - initial author * @version $Revision: 1.4 $ */ @@ -110,14 +108,19 @@ public class PropertiesFile extends Properties { public void load() { loaded = true; + InputStream s = null; try { if (!file.exists()) return; - InputStream s = new FileInputStream(file); - load(s); + try { + s = new FileInputStream(file); + load(s); + } finally { + if (s != null) s.close(); + } } catch (IOException ex) { - // eat + ex.printStackTrace(); } } @@ -128,11 +131,16 @@ public class PropertiesFile extends Properties { if (!loaded) return; // nothing could have changed so save unnecessary load/save + OutputStream s = null; try { - OutputStream s = new FileOutputStream(file); - store(s, header); + try { + s = new FileOutputStream(file); + store(s, header); + } finally { + if (s != null) s.close(); + } } catch (IOException ex) { - // eat + ex.printStackTrace(); } } |