A Java library to compress (e.g. LZW) a string

Nerd picture Nerd · Dec 29, 2013 · Viewed 7.5k times · Source

Apache Commons Compress works only with archive files (please correct me if I am wrong). I need something like

MyDB.put(LibIAmLookingFor.compress("My long string to store"));
String getBack = LibIAmLookingFor.decompress(MyDB.get()));

And LZW is just an example, could be anything similar. Thank you.

Answer

Tim B picture Tim B · Dec 29, 2013

Java has libraries built in for ZIP compression:

http://docs.oracle.com/javase/6/docs/api/java/util/zip/package-summary.html

Will that do what you need?