Changeset 16956 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2020-08-29T07:53:16+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GeoJSONReader.java
r16955 r16956 6 6 import java.io.BufferedInputStream; 7 7 import java.io.BufferedReader; 8 import java.io.ByteArrayInputStream;9 8 import java.io.IOException; 10 9 import java.io.InputStream; 11 10 import java.io.InputStreamReader; 11 import java.io.StringReader; 12 12 import java.nio.charset.StandardCharsets; 13 13 import java.util.List; … … 65 65 GeoJSONReader() { 66 66 // Restricts visibility 67 }68 69 private void parse(InputStream inputStream) throws IllegalDataException {70 try (JsonParser parser = Json.createParser(inputStream)) {71 parse(parser);72 } catch (JsonParsingException e) {73 throw new IllegalDataException(e);74 }75 67 } 76 68 … … 384 376 @Override 385 377 protected DataSet doParseDataSet(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException { 386 InputStream markSupported = source.markSupported() ? source : new BufferedInputStream(source);387 ds.setUploadPolicy(UploadPolicy.DISCOURAGED);388 if (isLineDelimited(markSupported)) {389 BufferedReader reader = new BufferedReader(new InputStreamReader(markSupported, StandardCharsets.UTF_8));390 String line = null;391 String rs = new String(new byte[]{RECORD_SEPARATOR_BYTE}, StandardCharsets.US_ASCII);392 try{393 while ((line = reader.readLine()) != null) {394 line = Utils.strip(line, rs);395 try (InputStream is = new ByteArrayInputStream(line.getBytes(StandardCharsets.UTF_8))) {396 parse(is);378 try (InputStream markSupported = source.markSupported() ? source : new BufferedInputStream(source)) { 379 ds.setUploadPolicy(UploadPolicy.DISCOURAGED); 380 if (isLineDelimited(markSupported)) { 381 try (BufferedReader reader = new BufferedReader(new InputStreamReader(markSupported, StandardCharsets.UTF_8))) { 382 String line; 383 String rs = new String(new byte[]{RECORD_SEPARATOR_BYTE}, StandardCharsets.US_ASCII); 384 while ((line = reader.readLine()) != null) { 385 line = Utils.strip(line, rs); 386 try (JsonParser parser = Json.createParser(new StringReader(line))) { 387 parse(parser); 388 } 397 389 } 398 390 } 399 } catch (IOException e) { 400 throw new IllegalDataException(e); 401 } 402 } else { 403 parse(markSupported); 391 } else { 392 try (JsonParser parser = Json.createParser(markSupported)) { 393 parse(parser); 394 } 395 } 396 } catch (IOException | JsonParsingException e) { 397 throw new IllegalDataException(e); 404 398 } 405 399 return getDataSet();
Note:
See TracChangeset
for help on using the changeset viewer.