- Timestamp:
- 2011-11-02T13:57:30+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r4555 r4564 452 452 new FileInputStream(getPreferencesDir()+"preferences"), "utf-8")); 453 453 /* FIXME: TODO: remove old style config file end of 2012 */ 454 in.mark(1); 455 int v = in.read(); 456 in.reset(); 457 if(v == '<') { 458 fromXML(in); 459 } else { 460 loadedXML = false; 461 int lineNumber = 0; 462 ArrayList<Integer> errLines = new ArrayList<Integer>(); 463 for (String line = in.readLine(); line != null; line = in.readLine(), lineNumber++) { 464 final int i = line.indexOf('='); 465 if (i == -1 || i == 0) { 466 errLines.add(lineNumber); 467 continue; 454 try { 455 in.mark(1); 456 int v = in.read(); 457 in.reset(); 458 if(v == '<') { 459 fromXML(in); 460 } else { 461 loadedXML = false; 462 int lineNumber = 0; 463 ArrayList<Integer> errLines = new ArrayList<Integer>(); 464 for (String line = in.readLine(); line != null; line = in.readLine(), lineNumber++) { 465 final int i = line.indexOf('='); 466 if (i == -1 || i == 0) { 467 errLines.add(lineNumber); 468 continue; 469 } 470 String key = line.substring(0,i); 471 String value = line.substring(i+1); 472 if (!value.isEmpty()) { 473 properties.put(key, value); 474 } 468 475 } 469 String key = line.substring(0,i); 470 String value = line.substring(i+1); 471 if (!value.isEmpty()) { 472 properties.put(key, value); 473 } 476 if (!errLines.isEmpty()) 477 throw new IOException(tr("Malformed config file at lines {0}", errLines)); 474 478 } 475 if (!errLines.isEmpty())476 throw new IOException(tr("Malformed config file at lines {0}", errLines));479 } finally { 480 in.close(); 477 481 } 478 482 } … … 551 555 JOptionPane.ERROR_MESSAGE 552 556 ); 557 if (backupFile.exists()) { 558 backupFile.delete(); 559 } 553 560 preferenceFile.renameTo(backupFile); 554 561 try {
Note:
See TracChangeset
for help on using the changeset viewer.