Java Utililty Methods GZip Byte Array Check

List of utility methods to do GZip Byte Array Check

Description

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

Method

booleanisGzip(byte[] bytes)
is Gzip
return (bytes != null && bytes.length > 2 && bytes[0] == (byte) 0x1F && bytes[1] == (byte) 0x8B);
booleanisGZipped(byte[] bytes)
is G Zipped
if ((bytes == null) || (bytes.length < 2)) {
    return false;
} else {
    return ((bytes[0] == (byte) (GZIPInputStream.GZIP_MAGIC))
            && (bytes[1] == (byte) (GZIPInputStream.GZIP_MAGIC >> 8)));
booleanisGzipped(byte[] data)
Determines if the data contained in the buffer is gzipped by matching the first 2 bytes with GZIP magic GZIP_MAGIC (0x8b1f).
if (data == null || data.length < 2) {
    return false;
int byte1 = data[0];
int byte2 = data[1] & 0xff; 
return (byte1 | (byte2 << 8)) == GZIPInputStream.GZIP_MAGIC;