/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }
/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }
/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }
/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }