Java Byte Array Uncompress uncompressGzip(byte[] b)

Here you can find the source of uncompressGzip(byte[] b)

Description

uncompress Gzip

License

Open Source License

Declaration

public static byte[] uncompressGzip(byte[] b) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2015 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from ww w. j  ava 2s  . c o  m*/
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

import java.io.BufferedInputStream;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import java.io.IOException;

import java.util.zip.GZIPInputStream;

public class Main {
    public static byte[] uncompressGzip(byte[] b) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try (BufferedInputStream in = new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(b)))) {
            int val;
            while ((val = in.read()) >= 0) {
                out.write(val);
            }
        }
        return out.toByteArray();
    }
}

Related

  1. uncompress(final byte[] src)
  2. uncompressByte(byte[] content)
  3. uncompressByteArray(byte[] ubytes, String type)
  4. uncompressByteArray(byte[] xmlByteArray)
  5. uncompressBytes(byte[] bytesToUncompress)
  6. uncompressObject(byte[] compressed)
  7. unCompressString(final byte[] data, final String encoding)
  8. unCompressToString(byte[] b)