Scenario: I have an XML doc (that I have converted to a String) which represents the KML file and I want to return a Zipped version of that file to save on bandwidth and the like. First of all you need to have somewhere to get the KML file from (in this case counter.getKML().
response.setContentType("application/vnd.google-earth.kmz");
ZipEntry entry = new ZipEntry("geoblog.kml");
ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream());
zipOutputStream.setLevel(9);
zipOutputStream.putNextEntry(entry);
zipOutputStream.write(counter.getKML().getBytes("UTF-8"));
zipOutputStream.closeEntry();
zipOutputStream.close();
And that is it. Mind bogglingly simple.
Technorati Tags: SOA, Service Architecture
1 comment:
Awesome!
Thanks this really helped me a lot.
Post a Comment