From 7402c4e21bd5da0b1e66da01b96a3fd9cd24e10e Mon Sep 17 00:00:00 2001 From: Denis Lila Date: Tue, 8 Mar 2011 14:48:34 -0500 Subject: Close streams after we're finished using them. --- .../jnlp/browser/FirefoxPreferencesFinder.java | 43 ++++++++++++---------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java') diff --git a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java index 34d1092..45f6faa 100644 --- a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java +++ b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesFinder.java @@ -85,31 +85,34 @@ public class FirefoxPreferencesFinder { */ // find the section with an entry Default=1 - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } - - line = line.trim(); - if (line.startsWith("[") && line.endsWith("]")) { - if (foundDefaultSection) { + try { + while (true) { + String line = reader.readLine(); + if (line == null) { break; } - // new section - linesInSection = new ArrayList(); - } else { - linesInSection.add(line); - int equalSignPos = line.indexOf('='); - if (equalSignPos > 0) { - String key = line.substring(0, equalSignPos).trim(); - String value = line.substring(equalSignPos+1).trim(); - if (key.toLowerCase().equals("default") && value.equals("1")) { - foundDefaultSection = true; + + line = line.trim(); + if (line.startsWith("[") && line.endsWith("]")) { + if (foundDefaultSection) { + break; + } + // new section + linesInSection = new ArrayList(); + } else { + linesInSection.add(line); + int equalSignPos = line.indexOf('='); + if (equalSignPos > 0) { + String key = line.substring(0, equalSignPos).trim(); + String value = line.substring(equalSignPos+1).trim(); + if (key.toLowerCase().equals("default") && value.equals("1")) { + foundDefaultSection = true; + } } } } - + } finally { + reader.close(); } if (!foundDefaultSection) { -- cgit v1.2.3