Java Decompress Byte Array decompressAndB64DecodeUTF8Bytes(byte[] b64EncodedCompressedBytes)

Here you can find the source of decompressAndB64DecodeUTF8Bytes(byte[] b64EncodedCompressedBytes)

Description

decompress And B Decode UTF Bytes

License

Apache License

Declaration

public static char[] decompressAndB64DecodeUTF8Bytes(byte[] b64EncodedCompressedBytes) throws Exception 

Method Source Code


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

import java.io.ByteArrayOutputStream;

import java.util.zip.Inflater;
import com.amazonaws.util.Base64;

public class Main {
    public static char[] decompressAndB64DecodeUTF8Bytes(byte[] b64EncodedCompressedBytes) throws Exception {

        byte[] input = Base64.decode(b64EncodedCompressedBytes);

        // Compressor with highest level of compression
        Inflater inflater = new Inflater();

        // Give the compressor the data to compress
        inflater.setInput(input);/*from   www . j a v a 2  s .  c o  m*/

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        byte[] buf = new byte[32];
        while (!inflater.finished()) {
            int count = inflater.inflate(buf);
            stream.write(buf, 0, count);
        }
        return new String(stream.toByteArray(), "UTF-8").toCharArray();
    }
}

Related

  1. decompress(byte[] src, Inflater decompresser, int compressCycleSize)
  2. decompress(byte[] str)
  3. decompress(byte[] zipByte)
  4. decompress(final byte[] compressed)
  5. decompress(final DataInputStream input, final byte[] result, int offset, int length)
  6. decompressByte(byte[] decompress)
  7. decompressByteArray(byte[] compressedData)
  8. decompressBytes(byte bytess[][])
  9. decompressBytes(byte[] input)