Changeset 16098 in josm for trunk/scripts
- Timestamp:
- 2020-03-09T00:35:01+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.java
r15879 r16098 5 5 6 6 import java.io.BufferedReader; 7 import java.io.BufferedWriter; 7 8 import java.io.IOException; 8 import java.io.InputStreamReader;9 import java.io.OutputStream;10 9 import java.io.OutputStreamWriter; 10 import java.io.Writer; 11 11 import java.lang.reflect.Field; 12 12 import java.net.MalformedURLException; 13 13 import java.net.URL; 14 import java.nio.charset.Charset; 14 15 import java.nio.file.Files; 15 16 import java.nio.file.Paths; … … 98 99 private static String josmInputFile = "imagery_josm.imagery.xml"; 99 100 private static String ignoreInputFile = "imagery_josm.ignores.txt"; 100 private static OutputStream outputFile; 101 private static OutputStreamWriter outputStream; 101 private static Writer outputStream; 102 102 private static String optionOutput; 103 103 private static boolean optionShorten; … … 132 132 script.loadJosmEntries(); 133 133 if (optionJosmXml != null) { 134 try ( OutputStreamWriter stream = new OutputStreamWriter(Files.newOutputStream(Paths.get(optionJosmXml)), UTF_8)) {135 script.printentries(script.josmEntries, stream);134 try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(optionJosmXml), UTF_8)) { 135 script.printentries(script.josmEntries, writer); 136 136 } 137 137 } 138 138 script.loadELIEntries(); 139 139 if (optionEliXml != null) { 140 try ( OutputStreamWriter stream = new OutputStreamWriter(Files.newOutputStream(Paths.get(optionEliXml)), UTF_8)) {141 script.printentries(script.eliEntries, stream);140 try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(optionEliXml), UTF_8)) { 141 script.printentries(script.eliEntries, writer); 142 142 } 143 143 } … … 147 147 if (outputStream != null) { 148 148 outputStream.close(); 149 }150 if (outputFile != null) {151 outputFile.close();152 149 } 153 150 } … … 216 213 217 214 if (optionOutput != null && !"-".equals(optionOutput)) { 218 outputFile = Files.newOutputStream(Paths.get(optionOutput)); 219 outputStream = new OutputStreamWriter(outputFile, optionEncoding != null ? optionEncoding : "UTF-8"); 215 outputStream = Files.newBufferedWriter(Paths.get(optionOutput), optionEncoding != null ? Charset.forName(optionEncoding) : UTF_8); 220 216 } else if (optionEncoding != null) { 221 217 outputStream = new OutputStreamWriter(System.out, optionEncoding); … … 244 240 void loadSkip() throws IOException { 245 241 final Pattern pattern = Pattern.compile("^\\|\\| *(ELI|Ignore) *\\|\\| *\\{\\{\\{(.+)\\}\\}\\} *\\|\\|"); 246 try (BufferedReader fr = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(ignoreInputFile)), UTF_8))) {242 try (BufferedReader fr = Files.newBufferedReader(Paths.get(ignoreInputFile), UTF_8)) { 247 243 String line; 248 244 … … 342 338 343 339 void loadELIEntries() throws IOException { 344 try (JsonReader jr = Json.createReader( new InputStreamReader(Files.newInputStream(Paths.get(eliInputFile)), UTF_8))) {340 try (JsonReader jr = Json.createReader(Files.newBufferedReader(Paths.get(eliInputFile), UTF_8))) { 345 341 eliEntries = jr.readObject().getJsonArray("features"); 346 342 } … … 408 404 } 409 405 410 void printentries(List<?> entries, OutputStreamWriter stream) throws IOException {406 void printentries(List<?> entries, Writer stream) throws IOException { 411 407 DecimalFormat df = new DecimalFormat("#.#######"); 412 408 df.setRoundingMode(java.math.RoundingMode.CEILING);
Note:
See TracChangeset
for help on using the changeset viewer.