Ignore:
Timestamp:
2012-07-25T02:31:52+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #7879 - Allow to open local and remote gzipped/bzipped osmChange files + remote osm.gz files + make some public constants of File filters to share between same importers/exporters

File:
1 edited

Legend:

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

    r3679 r5361  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.BufferedInputStream;
    67import java.io.File;
    78import java.io.IOException;
     9import java.io.InputStream;
    810import java.util.List;
     11import java.util.zip.GZIPInputStream;
    912
    1013import javax.swing.JOptionPane;
    1114
     15import org.apache.tools.bzip2.CBZip2InputStream;
    1216import org.openstreetmap.josm.Main;
    1317import org.openstreetmap.josm.actions.ExtensionFileFilter;
     
    97101        return (new Double(this.getPriority())).compareTo(other.getPriority());
    98102    }
     103   
     104    public static CBZip2InputStream getBZip2InputStream(InputStream in) throws IOException {
     105        if (in == null) {
     106            return null;
     107        }
     108        BufferedInputStream bis = new BufferedInputStream(in);
     109        int b = bis.read();
     110        if (b != 'B')
     111            throw new IOException(tr("Invalid bz2 file."));
     112        b = bis.read();
     113        if (b != 'Z')
     114            throw new IOException(tr("Invalid bz2 file."));
     115        return new CBZip2InputStream(bis);
     116    }
    99117
     118    public static GZIPInputStream getGZipInputStream(InputStream in) throws IOException {
     119        if (in == null) {
     120            return null;
     121        }
     122        return new GZIPInputStream(in);
     123    }
    100124}
Note: See TracChangeset for help on using the changeset viewer.