Java Byte Array Uncompress uncompressByteArray(byte[] xmlByteArray)

Here you can find the source of uncompressByteArray(byte[] xmlByteArray)

Description

uncompress the xmlByteArray

License

Open Source License

Declaration

public static byte[] uncompressByteArray(byte[] xmlByteArray) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import java.util.zip.GZIPInputStream;

public class Main {
    /**/*from  w  ww. j a v  a2  s .  c om*/
     * uncompress the xmlByteArray
     */
    public static byte[] uncompressByteArray(byte[] xmlByteArray) throws IOException {
        byte[] tmp = new byte[2048];
        int byteCount = 0;
        ByteArrayOutputStream uncompressedData = new ByteArrayOutputStream();
        GZIPInputStream gzipIS = new GZIPInputStream(new ByteArrayInputStream(xmlByteArray));

        while ((byteCount = gzipIS.read(tmp)) != -1) {
            uncompressedData.write(tmp, 0, byteCount);
        }

        return uncompressedData.toByteArray();
    }
}

Related

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