+ /**
+ * Use the given stream to access a remote zip file
+ * @param inStream stream to use to access file
+ */
+ public void openStream(InputStream inStream)
+ {
+ try
+ {
+ ZipInputStream zis = new ZipInputStream(inStream);
+ boolean xmlFound = false;
+ while (!xmlFound && zis.available() > 0)
+ {
+ ZipEntry entry = zis.getNextEntry();
+ String entryName = entry.toString();
+ if (entryName != null && entryName.length() > 4)
+ {
+ String suffix = entryName.substring(entryName.length()-4).toLowerCase();
+ if (suffix.equals(".kml") || suffix.equals(".gpx") || suffix.equals(".xml"))
+ {
+ _xmlLoader.reset();
+ SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
+ saxParser.parse(zis, _xmlLoader);
+ XmlHandler handler = _xmlLoader.getHandler();
+ if (handler == null) {
+ _app.showErrorMessage("error.load.dialogtitle", "error.load.othererror");
+ }
+ else {
+ // Send back to app
+ _app.informDataLoaded(handler.getFieldArray(), handler.getDataArray(),
+ Altitude.Format.METRES, new SourceInfo("gpsies", SourceInfo.FILE_TYPE.GPSIES),
+ handler.getTrackNameList());
+ xmlFound = true;
+ }
+ }
+ }
+ }
+ // Check whether there was an xml file inside
+ if (!xmlFound) {
+ _app.showErrorMessage("error.load.dialogtitle", "error.load.noxmlinzip");
+ }
+ }
+ catch (Exception e) {
+ System.err.println("ZipStream Error: " + e.getClass().getName() + " -message= " + e.getMessage());
+ }
+ }