X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fload%2Fxml%2FXmlFileLoader.java;h=454149f2c35cd432761edde2c8d271c50d2b3b15;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=3f1b2eb6fed19246785cf41a883e75a5c4b7f476;hpb=54b9d8bc8f0025ccf97a67d9dd217ef1f9cf082f;p=GpsPrune.git diff --git a/tim/prune/load/xml/XmlFileLoader.java b/tim/prune/load/xml/XmlFileLoader.java index 3f1b2eb..454149f 100644 --- a/tim/prune/load/xml/XmlFileLoader.java +++ b/tim/prune/load/xml/XmlFileLoader.java @@ -1,6 +1,9 @@ package tim.prune.load.xml; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; @@ -10,6 +13,7 @@ import org.xml.sax.helpers.DefaultHandler; import tim.prune.App; import tim.prune.I18nManager; import tim.prune.data.Altitude; +import tim.prune.data.SourceInfo; /** * Class for handling loading of Xml files, and passing the @@ -60,11 +64,13 @@ public class XmlFileLoader extends DefaultHandler implements Runnable */ public void run() { + FileInputStream inStream = null; try { // Construct a SAXParser and use this as a default handler SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); - saxParser.parse(_file, this); + inStream = new FileInputStream(_file); + saxParser.parse(inStream, this); // Check whether handler was properly instantiated if (_handler == null) @@ -76,8 +82,10 @@ public class XmlFileLoader extends DefaultHandler implements Runnable else { // Pass information back to app + SourceInfo sourceInfo = new SourceInfo(_file, + (_handler instanceof GpxHandler?SourceInfo.FILE_TYPE.GPX:SourceInfo.FILE_TYPE.KML)); _app.informDataLoaded(_handler.getFieldArray(), _handler.getDataArray(), - Altitude.Format.METRES, _file.getName()); + Altitude.Format.METRES, sourceInfo, _handler.getTrackNameList(), _handler.getLinkArray()); } } catch (Exception e) @@ -86,6 +94,9 @@ public class XmlFileLoader extends DefaultHandler implements Runnable _app.showErrorMessageNoLookup("error.load.dialogtitle", I18nManager.getText("error.load.othererror") + " " + e.getMessage()); } + finally { + try {inStream.close();} catch (IOException e2) {} + } }