Changeset 6080 in josm


Ignore:
Timestamp:
2013-07-22T15:21:30+02:00 (11 years ago)
Author:
bastiK
Message:

fixed #8893 - Cannot load GPX file

Location:
trunk/src/org/openstreetmap/josm/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r6070 r6080  
    88import java.io.IOException;
    99import java.io.InputStream;
     10import java.io.Reader;
    1011import java.util.ArrayList;
    1112import java.util.Collection;
     
    427428     */
    428429    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);
    431433    }
    432434
  • trunk/src/org/openstreetmap/josm/io/InvalidXmlCharacterFilter.java

    r6070 r6080  
    22package org.openstreetmap.josm.io;
    33
    4 import java.io.FilterInputStream;
    54import java.io.IOException;
    6 import java.io.InputStream;
     5import java.io.Reader;
    76
    87import org.openstreetmap.josm.Main;
     
    1918 * by space (0x20).
    2019 */
    21 public class InvalidXmlCharacterFilter extends FilterInputStream {
     20public class InvalidXmlCharacterFilter extends Reader {
     21
     22    private Reader reader;
    2223
    2324    public static boolean firstWarning = true;
     
    3536    }
    3637
    37     public InvalidXmlCharacterFilter(InputStream in) {
    38         super(in);
     38    public InvalidXmlCharacterFilter(Reader reader) {
     39        this.reader = reader;
    3940    }
    4041
    4142    @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);
    4945        if (n == -1) {
    5046            return -1;
     
    5652    }
    5753
    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) {
    5960        if (in < 0x20 && in >= 0 && INVALID_CHARS[in]) {
    6061            if (firstWarning) {
Note: See TracChangeset for help on using the changeset viewer.