public static boolean isGzipStream(byte[] bytes) {

        int minByteArraySize = 2;
        if (bytes == null || bytes.length < minByteArraySize) {
            return false;
        }

        return GZIPInputStream.GZIP_MAGIC == ((bytes[1] << 8 | bytes[0]) & 0xFFFF);
    }
@Test
    public void testIsGzipStream() {
        byte[] gzipBytes = new byte[2];
        gzipBytes[0] = (byte) GZIPInputStream.GZIP_MAGIC;
        gzipBytes[1] = (byte) (GZIPInputStream.GZIP_MAGIC >> 8);
        byte[] invalidGzipBytes = new byte[2];
        invalidGzipBytes[0] = (byte) (GZIPInputStream.GZIP_MAGIC + 1);
        invalidGzipBytes[1] = (byte) ((GZIPInputStream.GZIP_MAGIC >> 8) + 1);
        byte[] invalidGzipBytes2 = new byte[1];
        byte[] normalBytes = new byte[2];
        Assert.assertTrue(IoUtil.isGzipStream(gzipBytes));
        Assert.assertFalse(IoUtil.isGzipStream(invalidGzipBytes));
        Assert.assertFalse(IoUtil.isGzipStream(invalidGzipBytes2));
        Assert.assertFalse(IoUtil.isGzipStream(null));
        Assert.assertFalse(IoUtil.isGzipStream(normalBytes));
    }