Java Utililty Methods Byte Array Uncompress

List of utility methods to do Byte Array Uncompress

Description

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

Method

byte[]uncompressBytes(byte[] bytesToUncompress)
uncompress Bytes
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] data = new byte[16384];
int numberOfBytesRead;
try (GZIPInputStream zippedInputStream = new GZIPInputStream(new ByteArrayInputStream(bytesToUncompress))) {
    while ((numberOfBytesRead = zippedInputStream.read(data, 0, data.length)) != -1) {
        outputStream.write(data, 0, numberOfBytesRead);
    outputStream.flush();
...
byte[]uncompressGzip(byte[] b)
uncompress Gzip
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (BufferedInputStream in = new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(b)))) {
    int val;
    while ((val = in.read()) >= 0) {
        out.write(val);
return out.toByteArray();
...
ObjectuncompressObject(byte[] compressed)
uncompress Object
ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
GZIPInputStream gzis = new GZIPInputStream(bais);
ObjectInputStream ois = new ObjectInputStream(gzis);
return ois.readObject();
StringunCompressString(final byte[] data, final String encoding)
un Compress String
if (data == null || data.length == 0) {
    return null;
} else {
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    GZIPInputStream is = new GZIPInputStream(bais);
    byte[] tmp = new byte[256];
    while (true) {
...
StringunCompressToString(byte[] b)
un Compress To String
if (b == null || b.length == 0) {
    return null;
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayInputStream in = new ByteArrayInputStream(b);
try {
    GZIPInputStream gunzip = new GZIPInputStream(in);
    byte[] buffer = new byte[256];
...