Java Utililty Methods Uncompress Byte Array

List of utility methods to do Uncompress Byte Array

Description

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

Method

byte[]unzip(byte[] compressedData)
unzip
final Inflater decompressor = new Inflater();
decompressor.setInput(compressedData);
final ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);
byte[] buf = new byte[1024];
while (!decompressor.finished()) {
    try {
        int count = decompressor.inflate(buf);
        bos.write(buf, 0, count);
...
byte[]unzip(byte[] content)
unzip
int BUFFER_SIZE = 2048;
ByteArrayOutputStream out = new ByteArrayOutputStream();
ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(content));
ZipEntry entry = zin.getNextEntry();
if (entry != null) {
    int count;
    byte buffer[] = new byte[BUFFER_SIZE];
    BufferedOutputStream bout = new BufferedOutputStream(out, BUFFER_SIZE);
...
Stringunzip(byte[] content)
Method unzip
return new String(inflate(content));
StringunZip(byte[] contents)
decodes the byte array representing the zip file into a string.
return unZip(contents, null);
byte[]unzip(byte[] data)
unzip
InputStream in = new ByteArrayInputStream(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
    in = new GZIPInputStream(in);
    byte[] buffer = new byte[65536];
    int noRead;
    while ((noRead = in.read(buffer)) != -1) {
        out.write(buffer, 0, noRead);
...
byte[]unZip(byte[] data)
un Zip
byte[] b = null;
try {
    ByteArrayInputStream bis = new ByteArrayInputStream(data);
    ZipInputStream zip = new ZipInputStream(bis);
    while (zip.getNextEntry() != null) {
        byte[] buf = new byte[1024];
        int num = -1;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
...
byte[]unzip(byte[] data)
unzip
InputStream is = new ByteArrayInputStream(data);
GZIPInputStream gz = new GZIPInputStream(is);
List<Byte> l = new ArrayList<Byte>();
while (gz.available() != 0)
    l.add((byte) gz.read());
byte[] uncmp = new byte[l.size() - 1];
for (int i = 0; i < l.size() - 1; i++)
    uncmp[i] = l.get(i);
...
byte[]unzip(byte[] datas)
unzip
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayInputStream in = new ByteArrayInputStream(datas);
InflaterInputStream iin = new InflaterInputStream(in);
byte[] buffer = new byte[256];
int n;
while ((n = iin.read(buffer)) >= 0) {
    out.write(buffer, 0, n);
return out.toByteArray();
byte[]unzip(byte[] in)
Returns an gunzipped copy of the input array.
ByteArrayOutputStream outStream = new ByteArrayOutputStream(EXPECTED_COMPRESSION_RATIO * in.length);
GZIPInputStream inStream = new GZIPInputStream(new ByteArrayInputStream(in));
byte[] buf = new byte[BUF_SIZE];
while (true) {
    int size = inStream.read(buf);
    if (size <= 0)
        break;
    outStream.write(buf, 0, size);
...
StringunZip(byte[] input)
un Zip
ByteArrayInputStream inputStream = new ByteArrayInputStream(input);
InflaterInputStream in = new InflaterInputStream(inputStream);
ByteArrayOutputStream bout = new ByteArrayOutputStream(512);
byte[] buffer = new byte[2048];
int len = 0;
while ((len = in.read(buffer)) > 0) {
    bout.write(buffer, 0, len);
in.close();
bout.close();
return bout.toString(CHARACTER_ENCODING_UTF_8);