Reputation: 99
i am able to compress a base64 string areng the GZIP java compression method, so it is possible to get the compressed value in a st ring?
Upvotes: 1
Views: 2703
Reputation: 300
Yes, you can decompress gzip to string with this method.
public static String decompress(byte[] byteArray) throws Exception {
if (byteArray == null ) {
return null;
}
GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(byteArray));
BufferedReader bfr = new BufferedReader(new InputStreamReader(gzis, "UTF-8"));
String outputString = "";
String line;
while ((line=bfr.readLine())!=null) {
outputString += line;
}
return outputString;
}
Upvotes: 1