Here you can find the source of decompress(byte[] bytes)
Parameter | Description |
---|---|
bytes | bytes to be decompressed |
Parameter | Description |
---|---|
IOException | an exception |
public static String decompress(byte[] bytes) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.zip.GZIPInputStream; public class Main { /**/* ww w. j a v a2 s . c o m*/ * * @param bytes * bytes to be decompressed * @return a decompressed String * @throws IOException */ public static String decompress(byte[] bytes) throws IOException { if (bytes == null || bytes.length == 0) { return null; } GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes)); BufferedReader bf = new BufferedReader(new InputStreamReader(gis, "UTF-8")); String outStr = ""; String line; while ((line = bf.readLine()) != null) { outStr += line; } return outStr; } }