Changeset 6080 in josm
- Timestamp:
- 2013-07-22T15:21:30+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r6070 r6080 8 8 import java.io.IOException; 9 9 import java.io.InputStream; 10 import java.io.Reader; 10 11 import java.util.ArrayList; 11 12 import java.util.Collection; … … 427 428 */ 428 429 public GpxReader(InputStream source) throws IOException { 429 InputStream filtered = new InvalidXmlCharacterFilter(source); 430 this.inputSource = new InputSource(UTFInputStreamReader.create(filtered, "UTF-8")); 430 Reader utf8stream = UTFInputStreamReader.create(source, "UTF-8"); 431 Reader filtered = new InvalidXmlCharacterFilter(utf8stream); 432 this.inputSource = new InputSource(filtered); 431 433 } 432 434 -
trunk/src/org/openstreetmap/josm/io/InvalidXmlCharacterFilter.java
r6070 r6080 2 2 package org.openstreetmap.josm.io; 3 3 4 import java.io.FilterInputStream;5 4 import java.io.IOException; 6 import java.io. InputStream;5 import java.io.Reader; 7 6 8 7 import org.openstreetmap.josm.Main; … … 19 18 * by space (0x20). 20 19 */ 21 public class InvalidXmlCharacterFilter extends FilterInputStream { 20 public class InvalidXmlCharacterFilter extends Reader { 21 22 private Reader reader; 22 23 23 24 public static boolean firstWarning = true; … … 35 36 } 36 37 37 public InvalidXmlCharacterFilter( InputStream in) {38 super(in);38 public InvalidXmlCharacterFilter(Reader reader) { 39 this.reader = reader; 39 40 } 40 41 41 42 @Override 42 public int read() throws IOException { 43 return filter((byte)super.read()); 44 } 45 46 @Override 47 public int read(byte[] b, int off, int len) throws IOException { 48 int n = super.read(b, off, len); 43 public int read(char[] b, int off, int len) throws IOException { 44 int n = reader.read(b, off, len); 49 45 if (n == -1) { 50 46 return -1; … … 56 52 } 57 53 58 private byte filter(byte in) { 54 @Override 55 public void close() throws IOException { 56 reader.close(); 57 } 58 59 private char filter(char in) { 59 60 if (in < 0x20 && in >= 0 && INVALID_CHARS[in]) { 60 61 if (firstWarning) {
Note:
See TracChangeset
for help on using the changeset viewer.