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.
You have a plethora of choices -
You can use the java.util.Deflater for the Deflate algortihm,
But you may prefer to use a streaming compressor, like gzip with a GZIPOutputStream.
If you really want LZW, there are multiple implementations available.
If you need even better compression (at the cost of speed), you may want to use bzip2.
If you need even more speed (at the cost of compression), you may want to use lzo.