Where can I learn about text compression in Java?
What classes would be used, and how would I use them?
Where can I learn about text compression in Java?
What classes would be used, and how would I use them?
The Google results are very informative: http://java.sun.com/developer/technicalArticles/Programming/compression/
The java.util.zip
package contains GZIPInputStream
and GZipOutputStream
, you can easily combine those with other java.io
streams to do what you need.
Commons Codec provides some useful encoding/decoding classes as well.
Here's some example coding showing how to use Deflate, Filtered, bzip2, and lzma compression in Java. http://www.theeggeadventure.com/wikimedia/index.php/Java_Data_Compression
For most of the stream based classes, you add them inline with your existing Java IO methods. If you are reading or writing to a file, and can compress/uncompress by adding a filter to your stream. The same can be said for sockets and other IO.