Changeset 439 in josm
- Timestamp:
- 2007-10-29T17:07:53+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r344 r439 4 4 import java.io.BufferedReader; 5 5 import java.io.File; 6 import java.io.FileInputStream; 7 import java.io.FileOutputStream; 6 8 import java.io.FileReader; 7 9 import java.io.FileWriter; … … 12 14 import java.util.LinkedList; 13 15 import java.util.Map; 16 import java.util.Properties; 14 17 import java.util.SortedMap; 15 18 import java.util.StringTokenizer; … … 171 174 */ 172 175 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 173 181 try { 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(); 182 props.store(new FileOutputStream(getPreferencesDir() + "preferences"), null); 180 183 } catch (final IOException e) { 181 184 e.printStackTrace(); … … 186 189 187 190 public void load() throws IOException { 191 final Properties props = new Properties(); 192 props.load(new FileInputStream(getPreferencesDir()+"preferences")); 193 188 194 properties.clear(); 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)); 195 for (String key : props.stringPropertyNames()) { 196 properties.put(key, props.getProperty(key)); 196 197 } 197 198 }
Note:
See TracChangeset
for help on using the changeset viewer.