XML GZip compression utility classes

This is a small set of Java utility classes that makes it easy to parse/produce gzip-compressed XML. The code is in the public domain. This is a library for beginners, not for experts.

Usage

GZipStreamSource and GZipStreamResult can be used where you can use StreamSource and StreamResult. Thus these classes can be used to enable gzip support for things like XSLT, JAXB, dom4j, and JDOM. For example, to use gzip compressed stream as an input to XSLT, you could write:

Transformer t = ...;
t.transform( new GZipStreamSource(new File("input.xml")), new StreamResult(System.out) );

Another helper class in this package is GZipOutputStream, a java.util.GZIPOutputStream replacement that allows you to specify the compression level. This can be used for example to reduce the overhead of gzip compression at the server side.


Back to home