public int read(byte b[],int off,int len) throws IOException {
  if (inputStream == null) {
    throw new IOException("Stream closed");
  }
  int gotsofar=0;
  while (gotsofar < len) {
    int read=inputStream.read(b,off + gotsofar,len - gotsofar);
    if (read == -1) {
      if (gotsofar > 0) {
        count(gotsofar);
        return gotsofar;
      }
 else {
        return read;
      }
    }
 else {
      gotsofar+=read;
    }
  }
  count(gotsofar);
  return gotsofar;
}

public int read ( byte b [ ] , int off , int len ) throws IOException { if ( inputStream == null ) { throw new IOException ( "Stream closed" ) ; } int gotsofar = 0 ; while ( gotsofar < len ) { int read = inputStream . read ( b , off + gotsofar , len - gotsofar ) ; if ( read == - 1 ) { if ( gotsofar > 0 ) { count ( gotsofar ) ; return gotsofar ; } else { return read ; } } else { gotsofar += read ; } } count ( gotsofar ) ; return gotsofar ; }
read from the file
