private int readFully ( byte [ ] b , int offs , int len ) throws BitstreamException { int nRead = 0 ; try { while ( len > 0 ) { int bytesread = source . read ( b , offs , len ) ; if ( bytesread == - 1 ) { while ( len -- > 0 ) { b [ offs ++ ] = 0 ; } break ; //throw newBitstreamException(UNEXPECTED_EOF, new EOFException()); } nRead = nRead + bytesread ; offs += bytesread ; len -= bytesread ; } } catch ( IOException ex ) { throw newBitstreamException ( STREAM_ERROR , ex ) ; } return nRead ; }
Reads the exact number of bytes from the source input stream into a byte array .