Joop seems to have a solution there, but I feel like I have to add this: Compression in general, and GZIP in particular, will create a binary stream. You SHOULD NOT try to build a string from this thread - this is WILL .
If you need to switch to plain text representation, look at Base64 encoding, hexadecimal encoding, heck, even simple binary encoding.
In short, String objects are for things that people read. Byte arrays (and much more) are designed to read machines.
source share