Here you can find the source of gunzip(byte[] data)
@SuppressWarnings("PMD.AssignmentInOperand") static byte[] gunzip(byte[] data) throws IOException
//package com.java2s; /*/*from www. j a va 2 s .c o m*/ * Copyright 2014-2018 Netflix, Inc. * * 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.io.InputStream; import java.util.zip.GZIPInputStream; public class Main { /** Decompress a GZIP compressed byte array. */ @SuppressWarnings("PMD.AssignmentInOperand") static byte[] gunzip(byte[] data) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length * 10); try (InputStream in = new GZIPInputStream(new ByteArrayInputStream(data))) { byte[] buffer = new byte[4096]; int length; while ((length = in.read(buffer)) > 0) { baos.write(buffer, 0, length); } } return baos.toByteArray(); } }