Java Utililty Methods Decompress Byte Array

List of utility methods to do Decompress Byte Array

Description

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

Method

byte[]decompress(byte[] compressed)
decompress
GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(compressed));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int n;
while ((n = gis.read(buffer)) != -1)
    baos.write(buffer, 0, n);
return baos.toByteArray();
byte[]decompress(byte[] compressed)
decompress
return decompress(compressed, 0, compressed.length);
byte[]decompress(byte[] compressed)
decompress
if (compressed == null || compressed.length == 0) {
    return compressed;
ByteArrayInputStream sourceStream = new ByteArrayInputStream(compressed);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(compressed.length * 2);
try (GZIPInputStream compressor = new GZIPInputStream(sourceStream)) {
    ByteStreams.copy(compressor, outputStream);
    compressor.close();
...
Stringdecompress(byte[] compressed)
decompress
final int BUFFER_SIZE = 32;
ByteArrayInputStream is = new ByteArrayInputStream(compressed);
GZIPInputStream gis = new GZIPInputStream(is, BUFFER_SIZE);
StringBuilder string = new StringBuilder();
byte[] data = new byte[BUFFER_SIZE];
int bytesRead;
while ((bytesRead = gis.read(data)) != -1) {
    string.append(new String(data, 0, bytesRead));
...
byte[]decompress(byte[] compressedData)
decompress
ByteArrayOutputStream bytes = new ByteArrayOutputStream(compressedData.length);
GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(compressedData));
byte[] buffer = new byte[compressedData.length];
while (true) {
    int bytesRead = in.read(buffer, 0, buffer.length);
    if (bytesRead < 0) {
        return bytes.toByteArray();
    bytes.write(buffer, 0, bytesRead);
byte[]decompress(byte[] compressedData)
decompress
byte[] decompressedData;
Inflater decompressor = new Inflater();
decompressor.setInput(compressedData);
ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);
byte[] buf = new byte[1024];
while (!decompressor.finished()) {
    try {
        int count = decompressor.inflate(buf);
...
byte[]decompress(byte[] compressedData, int off, int len)
decompress
Inflater decompressor = new Inflater();
decompressor.setInput(compressedData, off, len);
ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);
byte[] buf = new byte[1024];
while (!decompressor.finished()) {
    int count = decompressor.inflate(buf);
    bos.write(buf, 0, count);
bos.close();
return bos.toByteArray();
byte[]decompress(byte[] data)
decompress
return decompress(data, 0, data.length);
byte[]decompress(byte[] data)
decompress
ByteArrayInputStream bais = new ByteArrayInputStream(data);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
decompress(bais, baos);
data = baos.toByteArray();
baos.flush();
baos.close();
bais.close();
return data;
...
Stringdecompress(byte[] data)
decompress
ByteArrayInputStream bais2 = new ByteArrayInputStream(data);
CheckedInputStream cis = new CheckedInputStream(bais2, new CRC32());
GZIPInputStream zis = new GZIPInputStream(new BufferedInputStream(cis));
InputStreamReader reader = new InputStreamReader(zis);
BufferedReader br = new BufferedReader(reader);
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = br.readLine()) != null) {
...