Changeset 7315 in josm for trunk/src/org/openstreetmap/josm/data/Preferences.java
- Timestamp:
- 2014-07-18T23:30:23+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r7248 r7315 8 8 import java.io.BufferedReader; 9 9 import java.io.File; 10 import java.io.FileInputStream;11 10 import java.io.FileOutputStream; 12 11 import java.io.IOException; 13 12 import java.io.InputStream; 14 import java.io.InputStreamReader;15 13 import java.io.OutputStreamWriter; 16 14 import java.io.PrintWriter; … … 20 18 import java.lang.reflect.Field; 21 19 import java.nio.charset.StandardCharsets; 20 import java.nio.file.Files; 22 21 import java.util.ArrayList; 23 22 import java.util.Collection; … … 57 56 import org.openstreetmap.josm.tools.I18n; 58 57 import org.openstreetmap.josm.tools.Utils; 58 import org.xml.sax.SAXException; 59 59 60 60 /** … … 790 790 } 791 791 792 public void load() throws Exception { 792 /** 793 * Loads preferences from settings file. 794 * @throws IOException if any I/O error occurs while reading the file 795 * @throws SAXException if the settings file does not contain valid XML 796 * @throws XMLStreamException if an XML error occurs while parsing the file (after validation) 797 */ 798 public void load() throws IOException, SAXException, XMLStreamException { 793 799 settingsMap.clear(); 794 800 File pref = getPreferenceFile(); 795 try (BufferedReader in = newBufferedReader(new InputStreamReader(new FileInputStream(pref), StandardCharsets.UTF_8))) {801 try (BufferedReader in = Files.newBufferedReader(pref.toPath(), StandardCharsets.UTF_8)) { 796 802 validateXML(in); 797 803 } 798 try (BufferedReader in = newBufferedReader(new InputStreamReader(new FileInputStream(pref), StandardCharsets.UTF_8))) {804 try (BufferedReader in = Files.newBufferedReader(pref.toPath(), StandardCharsets.UTF_8)) { 799 805 fromXML(in); 800 806 } … … 803 809 } 804 810 805 public void init(boolean reset){ 811 /** 812 * Initializes preferences. 813 * @param reset if {@code true}, current settings file is replaced by the default one 814 */ 815 public void init(boolean reset) { 806 816 // get the preferences. 807 817 File prefDir = getPreferencesDirFile(); … … 1388 1398 protected XMLStreamReader parser; 1389 1399 1390 public void validateXML(Reader in) throws Exception { 1400 public void validateXML(Reader in) throws IOException, SAXException { 1391 1401 SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 1392 1402 try (InputStream xsdStream = new CachedFile("resource://data/preferences.xsd").getInputStream()) {
Note:
See TracChangeset
for help on using the changeset viewer.
