How to check if InputStream is Gzipped?
It’s not foolproof but it’s probably the easiest and doesn’t rely on any external data. Like all decent formats, GZip too begins with a magic number which can be quickly checked without reading the entire stream. public static InputStream decompressStream(InputStream input) { PushbackInputStream pb = new PushbackInputStream( input, 2 ); //we need a pushbackstream to … Read more