/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if(streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if(streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if(streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if(streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if (streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }