public int read(byte b[],int off,int len) throws IOException {
  int numread=0;
  int copy;
  if (len < bytesinbuffer)   copy=len;
 else   copy=bytesinbuffer;
  numread+=copy;
  bytesinbuffer-=copy;
  System.arraycopy(buffer,curptr,b,off,copy);
  curptr+=copy;
  off+=copy;
  if (len == copy)   return numread;
  len-=copy;
  if (len > 512) {
    final int bcnt=super.read(b,off,len);
    firstbyteoffset+=(curptr + bcnt);
    curptr=0;
    return (numread + bcnt);
  }
 else {
    try {
      refillBuffer();
    }
 catch (    EOFException e) {
      if (numread >= 0) {
        numread=-1;
      }
      return numread;
    }
    return (numread + read(b,off,len));
  }
}

public int read ( byte b [ ] , int off , int len ) throws IOException { int numread = 0 ; int copy ; if ( len < bytesinbuffer ) copy = len ; else copy = bytesinbuffer ; numread += copy ; bytesinbuffer -= copy ; System . arraycopy ( buffer , curptr , b , off , copy ) ; curptr += copy ; off += copy ; if ( len == copy ) return numread ; len -= copy ; if ( len > 512 ) { final int bcnt = super . read ( b , off , len ) ; firstbyteoffset += ( curptr + bcnt ) ; curptr = 0 ; return ( numread + bcnt ) ; } else { try { refillBuffer ( ) ; } catch ( EOFException e ) { if ( numread >= 0 ) { numread = - 1 ; } return numread ; } return ( numread + read ( b , off , len ) ) ; } }
read from the file
