/** * * @param requiredSize * @throws IOException */ void refillBuffer(int requiredSize) throws IOException { // compute the actual position up to we have read something long currentPosition = bufferStart + buffer.position(); // if the buffer is not big enough enlarge it if(buffer.capacity() < requiredSize) { int size = buffer.capacity(); while(size < requiredSize) size *= 2; buffer = ByteBuffer.allocateDirect(size); buffer.order(order); } readBuffer(currentPosition); }
/** * Jumps the buffer to the specified position in the file * @param newPosition * @throws IOException */ public void goTo(long newPosition) throws IOException { // if the new position is already in the buffer, just move the buffer position // otherwise we have to reload it if(newPosition >= bufferStart && newPosition <= bufferStart + buffer.limit()) { buffer.position((int) (newPosition - bufferStart)); } else { readBuffer(newPosition); } }
/** * * @param requiredSize * @throws IOException */ void refillBuffer(int requiredSize) throws IOException { // compute the actual position up to we have read something long currentPosition = bufferStart + buffer.position(); // if the buffer is not big enough enlarge it if (buffer.capacity() < requiredSize) { int size = buffer.capacity(); while (size < requiredSize) size *= 2; buffer = NIOUtilities.allocate(size); buffer.order(order); } readBuffer(currentPosition); }
/** * * @param requiredSize * @throws IOException */ void refillBuffer(int requiredSize) throws IOException { // compute the actual position up to we have read something long currentPosition = bufferStart + buffer.position(); // if the buffer is not big enough enlarge it if (buffer.capacity() < requiredSize) { int size = buffer.capacity(); while (size < requiredSize) size *= 2; buffer = NIOUtilities.allocate(size); buffer.order(order); } readBuffer(currentPosition); }
/** * Jumps the buffer to the specified position in the file * * @param newPosition * @throws IOException */ public void goTo(long newPosition) throws IOException { // if the new position is already in the buffer, just move the // buffer position // otherwise we have to reload it if (useMemoryMapping || newPosition >= bufferStart && newPosition <= bufferStart + buffer.limit()) { buffer.position((int) (newPosition - bufferStart)); } else { readBuffer(newPosition); } }
/** * Jumps the buffer to the specified position in the file * * @param newPosition * @throws IOException */ public void goTo(long newPosition) throws IOException { // if the new position is already in the buffer, just move the // buffer position // otherwise we have to reload it if (useMemoryMapping || newPosition >= bufferStart && newPosition <= bufferStart + buffer.limit()) { buffer.position((int) (newPosition - bufferStart)); } else { readBuffer(newPosition); } }