aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
diff options
context:
space:
mode:
authorDenis Lila <[email protected]>2011-03-08 14:48:34 -0500
committerDenis Lila <[email protected]>2011-03-08 14:48:34 -0500
commit7402c4e21bd5da0b1e66da01b96a3fd9cd24e10e (patch)
tree17c6cf70ea92c253f85eac144a82798a0659995e /netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
parent261b0560100e15e376cb6bcf64eaabb5a79b24c5 (diff)
Close streams after we're finished using them.
Diffstat (limited to 'netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java')
-rw-r--r--netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java82
1 files changed, 43 insertions, 39 deletions
diff --git a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
index 1f206a9..9555b00 100644
--- a/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
+++ b/netx/net/sourceforge/jnlp/browser/FirefoxPreferencesParser.java
@@ -87,52 +87,56 @@ public final class FirefoxPreferencesParser {
BufferedReader reader = new BufferedReader(new FileReader(prefsFile));
- while (true) {
- String line = reader.readLine();
- // end of stream
- if (line == null) {
- break;
- }
-
- line = line.trim();
- if (line.startsWith("user_pref")) {
-
- /*
- * each line is of the form: user_pref("key",value); where value
- * can be a string in double quotes or an integer or float or
- * boolean
- */
-
- boolean foundKey = false;
- boolean foundValue = false;
-
- // extract everything inside user_pref( and );
- String pref = line.substring("user_pref(".length(), line.length() - 2);
- // key and value are separated by a ,
- int firstCommaPos = pref.indexOf(',');
- if (firstCommaPos >= 1) {
- String key = pref.substring(0, firstCommaPos).trim();
- if (key.startsWith("\"") && key.endsWith("\"")) {
- key = key.substring(1, key.length() - 1);
- if (key.trim().length() > 0) {
- foundKey = true;
- }
- }
+ try {
+ while (true) {
+ String line = reader.readLine();
+ // end of stream
+ if (line == null) {
+ break;
+ }
- if (pref.length() > firstCommaPos + 1) {
- String value = pref.substring(firstCommaPos + 1).trim();
- if (value.startsWith("\"") && value.endsWith("\"")) {
- value = value.substring(1, value.length() - 1).trim();
+ line = line.trim();
+ if (line.startsWith("user_pref")) {
+
+ /*
+ * each line is of the form: user_pref("key",value); where value
+ * can be a string in double quotes or an integer or float or
+ * boolean
+ */
+
+ boolean foundKey = false;
+ boolean foundValue = false;
+
+ // extract everything inside user_pref( and );
+ String pref = line.substring("user_pref(".length(), line.length() - 2);
+ // key and value are separated by a ,
+ int firstCommaPos = pref.indexOf(',');
+ if (firstCommaPos >= 1) {
+ String key = pref.substring(0, firstCommaPos).trim();
+ if (key.startsWith("\"") && key.endsWith("\"")) {
+ key = key.substring(1, key.length() - 1);
+ if (key.trim().length() > 0) {
+ foundKey = true;
+ }
}
- foundValue = true;
- if (foundKey && foundValue) {
- // System.out.println("added (\"" + key + "\", \"" + value + "\")");
- prefs.put(key, value);
+ if (pref.length() > firstCommaPos + 1) {
+ String value = pref.substring(firstCommaPos + 1).trim();
+ if (value.startsWith("\"") && value.endsWith("\"")) {
+ value = value.substring(1, value.length() - 1).trim();
+ }
+ foundValue = true;
+
+ if (foundKey && foundValue) {
+ // System.out.println("added (\"" + key + "\", \"" + value + "\")");
+ prefs.put(key, value);
+ }
}
}
}
}
+ } finally {
+ reader.close();
}
if (JNLPRuntime.isDebug()) {
System.out.println("Read " + prefs.size() + " entries from Firefox's preferences");