Compress a String. Store result as a String. Uncompress using stored String
807580Jun 19 2010 — edited Jun 20 2010Hi,
I am tring to compress a very long string, store the result as a string and then uncompress the stored result to the original string.
I have been using a GZIPOutputStream solution. The result of the compression using a println statement is "[B@3e25a5" which I unerstand is a byte[] array ( [B ) and Hex representation of the value.
How do I feed this value back into the uncompress function? When I try a:
try {
byte[] uncompressed = uncompress(compressed.toString().getBytes());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I get a:
java.io.IOException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:137)
Any help would be appreciated.
Ben