Java Ungzip Byte Array ungzip(byte[] buff)

Here you can find the source of ungzip(byte[] buff)

Description

ungzip

License

Apache License

Declaration

private static byte[] ungzip(byte[] buff) throws IOException 

Method Source Code


//package com.java2s;
/*// w ww.  j  a  va2 s.  c om
 * Copyright 2012 Krzysztof Otrebski
 *
 * 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.*;

import java.util.zip.GZIPInputStream;

public class Main {
    private static byte[] ungzip(byte[] buff) throws IOException {
        GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(buff));
        byte[] ungzippedRead = new byte[buff.length];
        int read = gzipInputStream.read(ungzippedRead);
        byte[] ungzipped = new byte[read];
        System.arraycopy(ungzippedRead, 0, ungzipped, 0, read);
        return ungzipped;
    }
}

Related

  1. unGZip(byte[] bContent)
  2. ungzip(byte[] bytes)
  3. unGZip(byte[] bytes)
  4. unGzip(byte[] data)
  5. unGZip(byte[] data)