code: public int read(byte b[], int off, int len) throws IOException
    {
      int total = 0;
      if (len == 0) {
        return 0;
      }
  
      int avail = count - pos - 2;
      if (avail <= 0) {
        fill();
        avail = count - pos - 2;
        if(avail <= 0) {
          return -1;
        }
      }
      int copy = Math.min(len, avail);
      System.arraycopy(buf, pos, b, off, copy);
      pos += copy;
      total += copy;
        
      while (total < len) {
        fill();
        avail = count - pos - 2;
        if(avail <= 0) {
          return total;
        }
        copy = Math.min(len - total, avail);
        System.arraycopy(buf, pos, b, off + total, copy);
        pos += copy;
        total += copy;
      }
      return total;
    }
docs: See the general contract of the <code>read</code>
  method of <code>InputStream</code>.
  <p>
  Returns <code>-1</code> (end of file) when the MIME
  boundary of this part is encountered.
  
  @param      b     the buffer into which the data is read.
  @param      off   the start offset of the data.
  @param      len   the maximum number of bytes read.
  @return     the total number of bytes read into the buffer, or
  <code>-1</code> if there is no more data because the end
  of the stream has been reached.
  @exception  IOException  if an I/O error occurs.