| Revision 3083,
1.2 KB
checked in by bastiK, 2 years ago
(diff) |
|
added svn:eol-style=native to source files
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | // License: GPL. For details, see LICENSE file. |
|---|
| 2 | package org.openstreetmap.josm.io; |
|---|
| 3 | |
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr; |
|---|
| 5 | |
|---|
| 6 | import java.io.BufferedInputStream; |
|---|
| 7 | import java.io.File; |
|---|
| 8 | import java.io.FileInputStream; |
|---|
| 9 | import java.io.IOException; |
|---|
| 10 | |
|---|
| 11 | import org.apache.tools.bzip2.CBZip2InputStream; |
|---|
| 12 | import org.openstreetmap.josm.actions.ExtensionFileFilter; |
|---|
| 13 | import org.openstreetmap.josm.gui.progress.ProgressMonitor; |
|---|
| 14 | |
|---|
| 15 | public class OsmBzip2Importer extends OsmImporter { |
|---|
| 16 | |
|---|
| 17 | public OsmBzip2Importer() { |
|---|
| 18 | super(new ExtensionFileFilter("osm.bz2,osm.bz", "osm.bz2", tr("OSM Server Files bzip2 compressed") |
|---|
| 19 | + " (*.osm.bz2 *.osm.bz)")); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | @Override |
|---|
| 23 | public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { |
|---|
| 24 | BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); |
|---|
| 25 | int b = bis.read(); |
|---|
| 26 | if (b != 'B') |
|---|
| 27 | throw new IOException(tr("Invalid bz2 file.")); |
|---|
| 28 | b = bis.read(); |
|---|
| 29 | if (b != 'Z') |
|---|
| 30 | throw new IOException(tr("Invalid bz2 file.")); |
|---|
| 31 | CBZip2InputStream in = new CBZip2InputStream(bis); |
|---|
| 32 | importData(in, file); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.