Here you can find the source of unZipByteToString(byte[] data)
public static String unZipByteToString(byte[] data)
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.zip.Inflater; public class Main { private final static int CacheSize = 1024; public static String unZipByteToString(byte[] data) { byte[] result = unZipByte(data); String outputString = null; try {/*from w ww . j a va 2 s . com*/ outputString = new String(result, 0, result.length, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return outputString; } public static byte[] unZipByte(byte[] data) { Inflater decompresser = new Inflater(); decompresser.setInput(data); byte result[] = new byte[0]; ByteArrayOutputStream o = new ByteArrayOutputStream(1); try { byte[] buf = new byte[CacheSize]; int got = 0; while (!decompresser.finished()) { got = decompresser.inflate(buf); o.write(buf, 0, got); } result = o.toByteArray(); } catch (Exception e) { e.printStackTrace(); } finally { try { o.close(); } catch (IOException e) { e.printStackTrace(); } decompresser.end(); } return result; } }