/** * Test for ZIP/GZIP stream signature. Wraps the input stream in a * BufferedInputStream. If ZIP/GZIP test is true wraps again in ZipInputStream/GZIPInputStream. * * @param in the InputStream. * @return the wrapped InputStream. * @throws IOException if operation failed. */ public static InputStream wrapAndCheckCompressionFormat( InputStream in ) throws IOException { BufferedInputStream bufferedIn = new BufferedInputStream( in ); if ( isZip( bufferedIn ) ) { ZipInputStream zipIn = new ZipInputStream( bufferedIn ); zipIn.getNextEntry(); return zipIn; } else if ( isGZip( bufferedIn ) ) { GZIPInputStream gzipIn = new GZIPInputStream( bufferedIn ); return gzipIn; } return bufferedIn; }