Changeset 7119 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2014-05-14T00:51:20+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/Compression.java
r7089 r7119 60 60 switch (this) { 61 61 case BZIP2: 62 return FileImporter.getBZip2InputStream(in);62 return Utils.getBZip2InputStream(in); 63 63 case GZIP: 64 return FileImporter.getGZipInputStream(in);64 return Utils.getGZipInputStream(in); 65 65 case ZIP: 66 return FileImporter.getZipInputStream(in);66 return Utils.getZipInputStream(in); 67 67 case NONE: 68 68 default: -
trunk/src/org/openstreetmap/josm/io/FileImporter.java
r7089 r7119 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.BufferedInputStream;7 6 import java.io.File; 8 7 import java.io.IOException; 9 import java.io.InputStream;10 import java.nio.charset.StandardCharsets;11 8 import java.util.List; 12 import java.util.zip.GZIPInputStream;13 import java.util.zip.ZipEntry;14 import java.util.zip.ZipInputStream;15 9 16 10 import javax.swing.JOptionPane; 17 11 18 import org.apache.tools.bzip2.CBZip2InputStream;19 12 import org.openstreetmap.josm.Main; 20 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; … … 138 131 } 139 132 140 public static CBZip2InputStream getBZip2InputStream(InputStream in) throws IOException {141 if (in == null) {142 return null;143 }144 BufferedInputStream bis = new BufferedInputStream(in);145 int b = bis.read();146 if (b != 'B')147 throw new IOException(tr("Invalid bz2 file."));148 b = bis.read();149 if (b != 'Z')150 throw new IOException(tr("Invalid bz2 file."));151 return new CBZip2InputStream(bis, /* see #9537 */ true);152 }153 154 public static GZIPInputStream getGZipInputStream(InputStream in) throws IOException {155 if (in == null) {156 return null;157 }158 return new GZIPInputStream(in);159 }160 161 public static ZipInputStream getZipInputStream(InputStream in) throws IOException {162 if (in == null) {163 return null;164 }165 ZipInputStream zis = new ZipInputStream(in, StandardCharsets.UTF_8);166 // Positions the stream at the beginning of first entry167 ZipEntry ze = zis.getNextEntry();168 if (ze != null && Main.isDebugEnabled()) {169 Main.debug("Zip entry: "+ze.getName());170 }171 return zis;172 }173 174 133 /** 175 134 * Returns the enabled state of this {@code FileImporter}. When enabled, it is listed and usable in "File->Open" dialog.
Note:
See TracChangeset
for help on using the changeset viewer.