I've been trying to figure out using GZIPOutputStream's and the like but have had no success with understanding them. All I want to do is convert a string of characters - "A string of characters" into a GZIP Base64 format. How can I do this?
EDIT: By GZIP Base64 format, I mean the string is first compressed using GZIP, then converted into Base64
We can use Java GZIPOutputStream/GZIInputStream and apache commons codec Base64 Encoder and Decoder:lifelongprogrammer.blogspot.com
Use the Apache Commons Codec
Base64OutputStream
.Here's a sample class:
Which outputs:
Under Linux, you can confirm this works with:
(Please note that on OSX, you should use
base64 -D
instead ofbase64 -d
in the above command)Which outputs: