public void setInput ( final InputStream input , final boolean binary ) throws IOException { if ( ! binary ) { int v = input . read ( ) ; StringBuilder buffer = new StringBuilder ( ) ; // Check for the no-zip flag boolean zipFlag = ( char ) v == ' ' ; if ( zipFlag ) { v = input . read ( ) ; } while ( v != - 1 ) { buffer . append ( ( char ) v ) ; v = input . read ( ) ; } if ( zipFlag ) { r = new BitReader ( inflateInput ( Base64 . decodeBase64 ( buffer . toString ( ) ) , 0 ) ) ; } else { r = new BitReader ( Base64 . decodeBase64 ( buffer . toString ( ) ) ) ; } } else { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; byte [ ] bData ; int l = input . available ( ) ; while ( l != 0 ) { bData = new byte [ l ] ; if ( input . read ( bData ) != l ) { throw new RuntimeException ( "ILLEGAL NUMBER OF BYTES READ" ) ; } stream . write ( bData ) ; l = input . available ( ) ; } if ( input . read ( ) != - 1 ) { throw new RuntimeException ( "END OF STREAM NOT REACHED" ) ; } bData = stream . toByteArray ( ) ; boolean zipFlag = bData [ 0 ] == - 128 ; if ( zipFlag ) { r = new BitReader ( inflateInput ( bData , 1 ) ) ; } else { r = new BitReader ( bData ) ; } } }
Assigns an input stream .