Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Compress a String. Store result as a String. Uncompress using stored String

807580Jun 19 2010 — edited Jun 20 2010
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 18 2010
Added on Jun 19 2010
18 comments
2,061 views