Lightweight Java compression library?
I'm开发者_开发问答 looking for a Java compression library that:
- is good for XML
- has a small footprint
- is fast (rather than achieves high compression ratio - speed is more important)
- easy to use
What do you guys suggest?
Thanks
There are XML minifiers, but for compression, XML is just plain text, very verbose and repetitive, but still only plain text. You will have to look at something like gzip, or any other general compression library and try them, there is no such thing as an XML specific compression library.
Java has some built in classes that can be used for the type of compression you're contemplating.
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/zip/Deflater.html
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/zip/Inflater.html
As to basic Java compression libraries, you can check out jvm-compressor-benchmark; two leading candidates in very-fast category would be Snappy-java and LZF -- former is fastest as it uses fast C codecs via JNI, and latter is fastest of pure Java codecs. Both work well for XML; while they don't get quite as good compression ratio as gzip (deflate), they are significantly faster: compression is typically 3-5x faster, and decompression 1.5 - 2x faster.
精彩评论