public int read() throws IOException {

    // If the file position is within the data, return the byte...
    if (filePosition < dataEnd) {
      int pos = (int) (filePosition - bufferStart);
      filePosition++;
      return (buffer[pos] & 0xff);

      // ...or should we indicate EOF...
    } else if (endOfFile) {
      return -1;

      // ...or seek to fill the buffer, and try again.
    } else {
      seek(filePosition);
      return read();
    }
  }
public int read ( ) throws IOException { if ( filePosition < dataEnd ) { int pos = ( int ) ( filePosition - bufferStart ) ; filePosition ++ ; return ( buffer [ pos ] & 0xff ) ; } else if ( endOfFile ) { return - 1 ; } else { seek ( filePosition ) ; return read ( ) ; } }
Read a byte of data from the file, blocking until data is
available.

@return the next byte of data, or -1 if the end of the file is
reached.
@throws IOException if an I/O error occurrs.