Java Byte Array Uncompress uncompressByte(byte[] content)

Here you can find the source of uncompressByte(byte[] content)

Description

uncompress Byte

License

Apache License

Declaration

public static byte[] uncompressByte(byte[] content) throws IOException 

Method Source Code


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

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

import java.io.IOException;

import java.util.zip.GZIPInputStream;

public class Main {
    public static byte[] uncompressByte(byte[] content) throws IOException {
        return uncompress(content).toByteArray();
    }/*from w w  w.j  a  v  a  2  s. c o  m*/

    public static ByteArrayOutputStream uncompress(byte[] content) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayInputStream in = new ByteArrayInputStream(content);
        GZIPInputStream gunzip = new GZIPInputStream(in);
        byte[] buffer = new byte[256];
        int n;
        while ((n = gunzip.read(buffer)) >= 0) {
            out.write(buffer, 0, n);
        }
        return out;
    }
}

Related

  1. uncompress(byte[] gzData, String charset)
  2. uncompress(byte[] input, int uncompr_len)
  3. uncompress(final byte[] buffer)
  4. uncompress(final byte[] compressedData)
  5. uncompress(final byte[] src)
  6. uncompressByteArray(byte[] ubytes, String type)
  7. uncompressByteArray(byte[] xmlByteArray)
  8. uncompressBytes(byte[] bytesToUncompress)
  9. uncompressGzip(byte[] b)