private final void switchCurrentBuffer() throws IOException {
   if (currentBufferIndex == file.numBuffers()) {
     currentBuffer = file.addBuffer(BUFFER_SIZE);
   } else {
     currentBuffer = file.getBuffer(currentBufferIndex);
   }
   bufferPosition = 0;
   bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex;
   bufferLength = currentBuffer.length;
 }
 private final void switchCurrentBuffer(boolean enforceEOF) throws IOException {
   bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex;
   if (currentBufferIndex >= file.numBuffers()) {
     // end of file reached, no more buffers left
     if (enforceEOF) {
       throw new EOFException("Read past EOF (resource: " + this + ")");
     } else {
       // Force EOF if a read takes place at this position
       currentBufferIndex--;
       bufferPosition = BUFFER_SIZE;
     }
   } else {
     currentBuffer = file.getBuffer(currentBufferIndex);
     bufferPosition = 0;
     long buflen = length - bufferStart;
     bufferLength = buflen > BUFFER_SIZE ? BUFFER_SIZE : (int) buflen;
   }
 }
 /** Returns byte usage of all buffers. */
 public long sizeInBytes() {
   return file.numBuffers() * BUFFER_SIZE;
 }