private byte [ ] readBytes ( InputStream is ) throws IOException { int totalRead = 0 ; byte [ ] content = new byte [ 1000000 ] ; while ( true ) { int howMany = is . read ( content , totalRead , content . length - totalRead ) ; if ( howMany < 0 ) { break ; } if ( howMany == 0 ) { continue ; } totalRead += howMany ; if ( totalRead >= content . length ) { byte [ ] tmp = content ; int newLength = ( ( content . length < 25000000 ) ? content . length * 2 : content . length + 5000000 ) ; content = new byte [ newLength ] ; System . arraycopy ( tmp , 0 , content , 0 , totalRead ) ; } } is . close ( ) ; byte [ ] results = new byte [ totalRead ] ; System . arraycopy ( content , 0 , results , 0 , totalRead ) ; return results ; }
Read the bytes in the given input stream .