Reading .KMZ in java

1,388 views
Skip to first unread message

HiFlite

unread,
Jul 5, 2007, 6:34:41 PM7/5/07
to KML Developer Support - Getting Started
I am trying to read a KMZ file from the USDA Forest Service:
http://activefiremaps.fs.fed.us/wms.php
see under "Continental United States", "KMZ: Download":
http://activefiremaps.fs.fed.us/kml/conus.kmz

it appears to work well if I copy-past this in the search for
maps.google.com:

http://maps.google.com/maps?f=q&hl=en&geocode=&q=http%3A%2F%2Factivefiremaps.fs.fed.us%2Fkml%2Fconus.kmz&ie=UTF8&ll=36.738884,-98.876953&spn=42.624304,74.794922&z=4&om=1

Ignore the syntax problems in the styleUrl.

Understanding that .KMZ is basically a zipped version of a .KML file,
I wrote following piece of code to unzip:

URL url = new URL("http://activefiremaps.fs.fed.us/kml/
conus.kmz");
HttpURLConnection http =
(HttpURLConnection)url.openConnection();
InputStream fin = http.getInputStream();
ZipInputStream zin = new ZipInputStream(fin);
zin.getNextEntry();
xr.parse(new InputSource(zin));

However I get an exception at the following line:
zin.getNextEntry();

Exception in thread "main" java.util.zip.ZipException: only DEFLATED
entries can have EXT descriptor
at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:
253)
at
java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:74)
at kmlloader.KMLInStreamer.main(KMLInStreamer.java:131)

Any idea what is going on?

Thanks,
Jo Desmet.


Reply all
Reply to author
Forward
0 new messages