Java Gunzip Byte Array gunzip(byte src[], byte default_value[])

Here you can find the source of gunzip(byte src[], byte default_value[])

Description

gunzip

License

BSD License

Declaration

static public byte[] gunzip(byte src[], byte default_value[]) 

Method Source Code


//package com.java2s;
//License from project: BSD License 

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

import java.util.zip.GZIPInputStream;

import com.amazonaws.util.IOUtils;

public class Main {
    static public byte[] gunzip(byte src[], byte default_value[]) {
        try {/*from  www . j  a  v  a  2s .  c  om*/
            if (src == null)
                return default_value;

            ByteArrayOutputStream out = new ByteArrayOutputStream();

            GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(src));

            IOUtils.copy(in, out);

            in.close();
            out.close();

            return out.toByteArray();
        } catch (Exception e) {
            return default_value;
        }
    }
}

Related

  1. gunzip(byte[] bytes)
  2. gunzip(byte[] bytes)
  3. gunzip(byte[] bytes)
  4. gunzip(byte[] contentBytes)