question: public static InputStream tryGzipInput ( InputStream in ) throws IOException { if ( ! in . markSupported ( ) ) { PushbackInputStream pb = new PushbackInputStream ( in , 16 ) ; in = pb ; byte [ ] magic = { 0 , 0 } ; pb . read ( magic ) ; pb . unread ( magic ) ; if ( magic [ 0 ] == 31 && magic [ 1 ] == - 117 ) { return new GZIPInputStream ( pb ) ; } return in ; } in . mark ( 16 ) ; boolean isgzip = ( in . read ( ) == 31 && in . read ( ) == - 117 ) ; in . reset ( ) ; if ( isgzip ) { in = new GZIPInputStream ( in ) ; } return in ; }
target:  Try to open a stream as gzip, if it starts with the gzip magic. TODO: move to utils package.