Package java.nio
Class MappedByteBuffer
- java.lang.Object
-
- java.nio.Buffer
-
- java.nio.ByteBuffer
-
- java.nio.MappedByteBuffer
-
- All Implemented Interfaces:
Comparable<ByteBuffer>
public abstract class MappedByteBuffer extends ByteBuffer
MappedByteBufferis a special kind of direct byte buffer which maps a region of file to memory.MappedByteBuffercan be created by callingFileChannel.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 theMappedByteBufferis undefined.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MappedByteBufferforce()Flushes changes made to the in-memory buffer back to the mapped file.booleanisLoaded()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.MappedByteBufferload()Attempts to load every page of this buffer into RAM.-
Methods inherited from class java.nio.ByteBuffer
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, order, order, put, put, put, put, put, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putLong, putLong, putShort, putShort, setAccessible, slice, wrap, wrap
-
-
-
-
Method Detail
-
isLoaded
public final 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. It is impossible to give a strong guarantee since this is only a snapshot of a dynamic situation.
-
load
public final MappedByteBuffer load()
Attempts to load every page of this buffer into RAM. SeeisLoaded().- Returns:
- this buffer.
-
force
public final MappedByteBuffer force()
Flushes changes made to the in-memory buffer back to the mapped file. Unless you call this, changes may not be written back until the finalizer runs. This method waits for the write to complete before returning.- Returns:
- this buffer.
-
-