Java Utililty Methods GZip InputStream Check

List of utility methods to do GZip InputStream Check

Description

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

Method

booleanisGZip(BufferedInputStream instream)
Test for GZIP stream signature.
instream.mark(2);
byte[] b = new byte[2];
try {
    instream.read(b, 0, 2);
} catch (Exception ex) {
    throw new RuntimeException("Couldn't read header from stream ", ex);
try {
...
booleanisGZIPCompressed(InputStream in)
Indicates whether an InputStream is GZIP compressed.
if (!in.markSupported()) {
    throw new IllegalArgumentException("InputStream must support mark()!");
byte[] data = new byte[2];
in.mark(2);
in.read(data);
in.reset();
return ((data[0] == GZIP_MAGIC[0]) && (data[1] == GZIP_MAGIC[1]));
...
booleanisGZipped(InputStream in)
Checks if an input stream is gzipped.
int magic = 0;
try {
    if (!in.markSupported()) {
        in = new BufferedInputStream(in);
    in.mark(2);
    try {
        magic = in.read() & 0xff | ((in.read() << 8) & 0xff00);
...
booleanisGZipped(InputStream in)
is G Zipped
if (!in.markSupported()) {
    in = new BufferedInputStream(in);
in.mark(2);
int magic = 0;
try {
    magic = in.read() & 0xff | ((in.read() << 8) & 0xff00);
    in.reset();
...
booleanisGzipStm(InputStream in)
is Gzip Stm
boolean ms = in.markSupported();
if (ms)
    in.mark(10);
int b1 = in.read();
int b2 = in.read();
if (ms)
    in.reset();
return ((b2 << 8 | b1) == GZIPInputStream.GZIP_MAGIC);
...