public abstract class MappedByteBuffer extends ByteBuffer
MappedByteBuffer is a special kind of direct byte buffer which maps a
region of file to memory.
MappedByteBuffer can be created by calling
FileChannel.map.
Once created, the mapping between the byte buffer and the file region remains
valid until the byte buffer is garbage collected.
All or part of a MappedByteBuffer's content may change or become
inaccessible at any time, since the mapped file region can be modified by
another thread or process at any time. If this happens, the behavior of the
MappedByteBuffer is undefined.
| Modifier and Type | Method and Description |
|---|---|
MappedByteBuffer |
clear()
Clears this buffer.
|
MappedByteBuffer |
flip()
Flips this buffer.
|
MappedByteBuffer |
force()
Flushes changes made to the in-memory buffer back to the mapped file.
|
boolean |
isLoaded()
Returns true if there is a high probability that every page of this buffer is currently
loaded in RAM, meaning that accesses will not cause a page fault.
|
MappedByteBuffer |
limit(int newLimit)
Sets the limit of this buffer.
|
MappedByteBuffer |
load()
Attempts to load every page of this buffer into RAM.
|
MappedByteBuffer |
mark()
Marks the current position, so that the position may return to this point
later by calling
reset(). |
MappedByteBuffer |
position(int newPosition)
Sets the position of this buffer.
|
MappedByteBuffer |
reset()
Resets the position of this buffer to the
mark. |
MappedByteBuffer |
rewind()
Rewinds this buffer.
|
allocate, allocateDirect, array, arrayOffset, asCharBuffer, asDoubleBuffer, asFloatBuffer, asIntBuffer, asLongBuffer, asReadOnlyBuffer, asShortBuffer, compact, compareTo, duplicate, equals, get, get, get, get, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, hasArray, hashCode, isAccessible, isDirect, mismatch, order, order, put, put, put, put, put, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putLong, putLong, putShort, putShort, setAccessible, slice, wrap, wrapcapacity, getElementSizeShift, hasRemaining, isReadOnly, limit, position, remaining, toStringpublic final boolean isLoaded()
public final MappedByteBuffer load()
isLoaded().public final MappedByteBuffer force()
public final MappedByteBuffer position(int newPosition)
If the mark is set and it is greater than the new position, then it is cleared.
position in class ByteBuffernewPosition - the new position, must be not negative and not greater than
limit.public final MappedByteBuffer limit(int newLimit)
If the current position in the buffer is in excess of
newLimit then, on returning from this call, it will have
been adjusted to be equivalent to newLimit. If the mark
is set and is greater than the new limit, then it is cleared.
limit in class ByteBuffernewLimit - the new limit, must not be negative and not greater than
capacity.public final MappedByteBuffer mark()
reset().mark in class ByteBufferpublic final MappedByteBuffer reset()
mark.reset in class ByteBufferpublic final MappedByteBuffer clear()
While the content of this buffer is not changed, the following internal changes take place: the current position is reset back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is cleared.
clear in class ByteBufferpublic final MappedByteBuffer flip()
The limit is set to the current position, then the position is set to zero, and the mark is cleared.
The content of this buffer is not changed.
flip in class ByteBufferpublic final MappedByteBuffer rewind()
The position is set to zero, and the mark is cleared. The content of this buffer is not changed.
rewind in class ByteBuffer