Changeset 441 in josm for trunk/src/org
- Timestamp:
- 2007-10-30T02:41:13+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r439 r441 4 4 import java.io.BufferedReader; 5 5 import java.io.File; 6 import java.io.FileInputStream;7 import java.io.FileOutputStream;8 6 import java.io.FileReader; 9 7 import java.io.FileWriter; … … 14 12 import java.util.LinkedList; 15 13 import java.util.Map; 16 import java.util.Properties;17 14 import java.util.SortedMap; 18 15 import java.util.StringTokenizer; … … 174 171 */ 175 172 protected void save() { 176 final Properties props = new Properties();177 for (Map.Entry<String, String> e : properties.entrySet()) {178 props.setProperty(e.getKey(), e.getValue());179 }180 181 173 try { 182 props.store(new FileOutputStream(getPreferencesDir() + "preferences"), null); 174 final PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir() + "preferences"), false); 175 for (final Entry<String, String> e : properties.entrySet()) { 176 if (!e.getValue().equals("")) 177 out.println(e.getKey() + "=" + e.getValue()); 178 } 179 out.close(); 183 180 } catch (final IOException e) { 184 181 e.printStackTrace(); … … 189 186 190 187 public void load() throws IOException { 191 final Properties props = new Properties();192 props.load(new FileInputStream(getPreferencesDir()+"preferences"));193 194 188 properties.clear(); 195 for (String key : props.stringPropertyNames()) { 196 properties.put(key, props.getProperty(key)); 189 final BufferedReader in = new BufferedReader(new FileReader(getPreferencesDir()+"preferences")); 190 int lineNumber = 0; 191 for (String line = in.readLine(); line != null; line = in.readLine(), lineNumber++) { 192 final int i = line.indexOf('='); 193 if (i == -1 || i == 0) 194 throw new IOException("Malformed config file at line "+lineNumber); 195 properties.put(line.substring(0,i), line.substring(i+1)); 197 196 } 198 197 }
Note:
See TracChangeset
for help on using the changeset viewer.