Skip to content

Most visited

Recently visited

navigation
Added in API level 1

MappedByteBuffer

public abstract class MappedByteBuffer
extends ByteBuffer

java.lang.Object
   ↳ java.nio.Buffer
     ↳ java.nio.ByteBuffer
       ↳ java.nio.MappedByteBuffer


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.

Summary

Public methods

final MappedByteBuffer force()

Flushes changes made to the in-memory buffer back to the mapped file.

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.

final MappedByteBuffer load()

Attempts to load every page of this buffer into RAM.

Inherited methods

From class java.nio.ByteBuffer
From class java.nio.Buffer
From class java.lang.Object
From interface java.lang.Comparable

Public methods

force

Added in API level 1
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
MappedByteBuffer this buffer.

isLoaded

Added in API level 1
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.

Returns
boolean

load

Added in API level 1
MappedByteBuffer load ()

Attempts to load every page of this buffer into RAM. See isLoaded().

Returns
MappedByteBuffer this buffer.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.