Here you can find the source of unGZip(byte[] bytes)
public final static byte[] unGZip(byte[] bytes) throws IOException
//package com.java2s; /*// w ww .ja v a 2 s. c o m * Copyright Bruce Liang (ldcsaa@gmail.com) * * Version : JessMA 3.5.1 * Author : Bruce Liang * Website : http://www.jessma.org * Project : http://www.oschina.net/p/portal-basic * Blog : http://www.cnblogs.com/ldcsaa * WeiBo : http://weibo.com/u/1402935851 * QQ Group : 75375912 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; public class Main { public final static byte[] unGZip(byte[] bytes) throws IOException { byte[] buffer = new byte[4096]; ByteArrayInputStream bis = new ByteArrayInputStream(bytes); GZIPInputStream gzip = new GZIPInputStream(bis); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { int r; while ((r = gzip.read(buffer, 0, buffer.length)) != -1) baos.write(buffer, 0, r); return baos.toByteArray(); } finally { try { if (baos != null) baos.close(); if (gzip != null) gzip.close(); if (bis != null) bis.close(); } catch (IOException e) { } } } }