public int read() throws IOException {
  if (pos >= 0) {
    int cur=pos % BUFF_SIZE;
    if (cur < bar) {
      pos++;
      return buff[cur];
    }
    if (cur != end) {
      buff[cur]=inStream.read();
      bar=cur + 1;
      pos++;
      return buff[cur];
    }
 else {
      pos=-1;
    }
  }
  return inStream.read();
}

public int read ( ) throws IOException { if ( pos >= 0 ) { int cur = pos % BUFF_SIZE ; if ( cur < bar ) { pos ++ ; return buff [ cur ] ; } if ( cur != end ) { buff [ cur ] = inStream . read ( ) ; bar = cur + 1 ; pos ++ ; return buff [ cur ] ; } else { pos = - 1 ; } } return inStream . read ( ) ; }
reads the byte from the stream . if mark has been set up and was not invalidated byte is read from the underlying stream and saved into the buffer . if the current read position has been reset to the marked position and there are remaining bytes in the buffer , the byte is taken from it . in the other cases ( if mark has been invalidated , or there are no buffered bytes ) the byte is taken directly from the underlying stream and it is returned without saving to the buffer .
