use of org.openstreetmap.osmosis.core.OsmosisRuntimeException in project GeoGig by boundlessgeo.
the class XmlReader method run.
/**
* Reads all data from the file and send it to the sink.
*/
public void run() {
InputStream inputStream = this.file;
try {
SAXParser parser;
sink.initialize(Collections.<String, Object>emptyMap());
// make "-" an alias for /dev/stdin
// if (file.getName().equals("-")) {
// inputStream = System.in;
// } else {
// inputStream = new FileInputStream(file);
// }
inputStream = new CompressionActivator(compressionMethod).createCompressionInputStream(inputStream);
parser = createParser();
parser.parse(inputStream, new OsmHandler(sink, enableDateParsing));
sink.complete();
} catch (SAXParseException e) {
throw new OsmosisRuntimeException("Unable to parse xml file " + file + ". publicId=(" + e.getPublicId() + "), systemId=(" + e.getSystemId() + "), lineNumber=" + e.getLineNumber() + ", columnNumber=" + e.getColumnNumber() + ".", e);
} catch (SAXException e) {
throw new OsmosisRuntimeException("Unable to parse XML.", e);
} catch (IOException e) {
throw new OsmosisRuntimeException("Unable to read XML file " + file + ".", e);
} finally {
sink.release();
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.log(Level.SEVERE, "Unable to close input stream.", e);
}
inputStream = null;
}
}
}
Aggregations