Changeset 7315 in josm
- Timestamp:
- 2014-07-18T23:30:23+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r7082 r7315 10 10 import java.io.BufferedReader; 11 11 import java.io.File; 12 import java.io.FileInputStream;13 12 import java.io.IOException; 14 import java.io.InputStreamReader;15 13 import java.nio.charset.StandardCharsets; 14 import java.nio.file.Files; 16 15 import java.util.ArrayList; 17 16 import java.util.Arrays; … … 292 291 293 292 for (File urlFile: urlFiles) { 294 try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(urlFile), StandardCharsets.UTF_8))) {293 try (BufferedReader reader = Files.newBufferedReader(urlFile.toPath(), StandardCharsets.UTF_8)) { 295 294 String line; 296 295 while ((line = reader.readLine()) != null) { -
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r7082 r7315 7 7 import java.io.File; 8 8 import java.io.FileFilter; 9 import java.io.FileInputStream;10 9 import java.io.IOException; 11 import java.io.InputStreamReader;12 10 import java.io.PrintStream; 13 11 import java.lang.management.ManagementFactory; 14 12 import java.nio.charset.StandardCharsets; 13 import java.nio.file.Files; 15 14 import java.util.ArrayList; 16 15 import java.util.Date; … … 303 302 File pidFile = getPidFile(file); 304 303 if (pidFile.exists()) { 305 try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(pidFile), StandardCharsets.UTF_8))) {304 try (BufferedReader reader = Files.newBufferedReader(pidFile.toPath(), StandardCharsets.UTF_8)) { 306 305 String jvmId = reader.readLine(); 307 306 if (jvmId != null) { -
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 = new BufferedReader(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 = new BufferedReader(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()) { -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r7082 r7315 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.BufferedReader;7 6 import java.io.File; 8 import java.io.FileInputStream;9 7 import java.io.FileNotFoundException; 10 8 import java.io.FileOutputStream; 11 9 import java.io.IOException; 12 import java.io.InputStreamReader;13 10 import java.io.OutputStreamWriter; 14 11 import java.io.PrintWriter; 15 12 import java.nio.charset.StandardCharsets; 13 import java.nio.file.Files; 14 import java.nio.file.Path; 15 import java.nio.file.Paths; 16 16 import java.util.ArrayList; 17 17 import java.util.Arrays; … … 170 170 ignoredErrors.clear(); 171 171 if (Main.pref.getBoolean(ValidatorPreference.PREF_USE_IGNORE, true)) { 172 File file = new File(getValidatorDir() + "ignorederrors"); 173 if (file.exists()) { 174 try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { 175 for (String line = in.readLine(); line != null; line = in.readLine()) { 176 ignoredErrors.add(line); 177 } 172 Path path = Paths.get(getValidatorDir() + "ignorederrors"); 173 if (Files.exists(path)) { 174 try { 175 ignoredErrors.addAll(Files.readAllLines(path, StandardCharsets.UTF_8)); 178 176 } catch (final FileNotFoundException e) { 179 177 Main.debug(Main.getErrorMessage(e)); -
trunk/src/org/openstreetmap/josm/io/GeoJSONExporter.java
r7214 r7315 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.BufferedWriter;7 6 import java.io.File; 8 import java.io.FileOutputStream;9 7 import java.io.IOException; 10 import java.io.OutputStreamWriter;11 8 import java.io.Writer; 12 9 import java.nio.charset.StandardCharsets; 10 import java.nio.file.Files; 13 11 14 12 import org.openstreetmap.josm.actions.ExtensionFileFilter; … … 32 30 if (layer instanceof OsmDataLayer) { 33 31 String json = new GeoJSONWriter((OsmDataLayer) layer).write(); 34 try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {32 try (Writer out = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { 35 33 out.write(json); 36 34 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r7314 r7315 10 10 import java.io.BufferedReader; 11 11 import java.io.File; 12 import java.io.FileInputStream;13 12 import java.io.IOException; 14 13 import java.io.InputStreamReader; … … 17 16 import java.nio.charset.StandardCharsets; 18 17 import java.nio.file.Files; 18 import java.nio.file.Path; 19 19 import java.nio.file.Paths; 20 20 import java.security.KeyStore; … … 278 278 String result = null; 279 279 if (path != null) { 280 File file = new File(path);281 if ( file.exists()) {282 try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {280 Path p = Paths.get(path); 281 if (Files.exists(p)) { 282 try (BufferedReader reader = Files.newBufferedReader(p, StandardCharsets.UTF_8)) { 283 283 String id = null; 284 284 String release = null;
Note:
See TracChangeset
for help on using the changeset viewer.