Java Utililty Methods Gunzip Byte Array

List of utility methods to do Gunzip Byte Array

Description

The list of methods to do Gunzip Byte Array are organized into topic(s).

Method

byte[]gunzip(byte src[], byte default_value[])
gunzip
try {
    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();
...
Stringgunzip(byte[] bytes)
gunzip
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
BufferedInputStream bufis = new BufferedInputStream(new GZIPInputStream(bis));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = bufis.read(buffer)) >= 0) {
    bos.write(buffer, 0, len);
String retval = bos.toString();
bis.close();
bufis.close();
bos.close();
return retval;
byte[]gunzip(byte[] bytes)
Uncompresses a GZIP file.
try (InputStream is = new GZIPInputStream(new ByteArrayInputStream(bytes))) {
    try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
        byte[] buf = new byte[4096];
        int len;
        while ((len = is.read(buf, 0, buf.length)) != -1) {
            os.write(buf, 0, len);
        return os.toByteArray();
...
byte[]gunzip(byte[] bytes)
Decompresses the given byte array in the GZIP file format.
if (bytes == null)
    return null;
if (bytes.length == 0)
    return new byte[0];
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
byte[] result = null;
try (GZIPInputStream gzip = new GZIPInputStream(bin);
        ByteArrayOutputStream bout = new ByteArrayOutputStream()) {
...
byte[]gunzip(byte[] contentBytes)
gunzip
ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
byte[] result = out.toByteArray();
out.close();
return result;
byte[]gunzip(byte[] data)
gunzip
InputStream in = new GZIPInputStream(new ByteArrayInputStream(data));
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteStreams.copy(in, out);
return out.toByteArray();
byte[]gunzip(byte[] data)
Decompress a GZIP compressed byte array.
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();
byte[]gunzip(byte[] data)
Do a g-unzip operation.
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(10240);
GZIPInputStream input = null;
try {
    input = new GZIPInputStream(new ByteArrayInputStream(data));
    byte[] buffer = new byte[1024];
    int n = 0;
    for (;;) {
        n = input.read(buffer);
...
Stringgunzip(byte[] in)
gunzip
GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(in));
BufferedReader bf = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
String outStr = "";
String line;
while ((line = bf.readLine()) != null)
    outStr += line;
return outStr;
Tgunzip(final byte[] b, final Class c)
return JSON form.
if (b == null) {
    return null;
try (final GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(b))) {
    return MAPPER.readValue(in, c);