package tim.prune.load.xml;
import java.io.File;
+import java.io.FileInputStream;
+
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
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
*/
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)
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());
}
}
catch (Exception e)
{
+ // clean up file stream
+ try {
+ inStream.close();
+ }
+ catch (Exception e2) {}
// Show error dialog
_app.showErrorMessageNoLookup("error.load.dialogtitle",
I18nManager.getText("error.load.othererror") + " " + e.getMessage());