int read(byte[] buffer,int offset,int length) throws IOException {
  int readLength=0;
  while (length > 0) {
    while (_chunkLength <= 0) {
      if (_isLastChunk)       return readLength == 0 ? -1 : readLength;
      int code=read();
switch (code) {
case 'b':
        _isLastChunk=false;
      _chunkLength=(read() << 8) + read();
    break;
case 'B':
  _isLastChunk=true;
_chunkLength=(read() << 8) + read();
break;
default :
throw expect("byte[]",code);
}
}
int sublen=_chunkLength;
if (length < sublen) sublen=length;
sublen=_is.read(buffer,offset,sublen);
offset+=sublen;
readLength+=sublen;
length-=sublen;
_chunkLength-=sublen;
}
return readLength;
}

int read ( byte [ ] buffer , int offset , int length ) throws IOException { int readLength = 0 ; while ( length > 0 ) { while ( _chunkLength <= 0 ) { if ( _isLastChunk ) return readLength == 0 ? - 1 : readLength ; int code = read ( ) ; switch ( code ) { case 'b' : _isLastChunk = false ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; break ; case 'B' : _isLastChunk = true ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; break ; default : throw expect ( "byte[]" , code ) ; } } int sublen = _chunkLength ; if ( length < sublen ) sublen = length ; sublen = _is . read ( buffer , offset , sublen ) ; offset += sublen ; readLength += sublen ; length -= sublen ; _chunkLength -= sublen ; } return readLength ; }
reads bytes from the underlying stream .
