Name
MappedByteBuffer
Synopsis
This
class
is a ByteBuffer
that represents a memory-mapped
portion of a file. Create a MappedByteBuffer
by
calling the map( )
method of a
java.nio.channels.FileChannel
. All
MappedByteBuffer
buffers are
direct
buffers.
isLoaded( )
returns a hint as to whether the
contents of the buffer are currently in primary memory (as opposed to
resident on disk). If it returns true
, then
operations on the buffer will probably execute very quickly. The
load( )
method requests (but does not require) that the operating system load
the buffer contents into primary memory. It is not guaranteed to
succeed. For buffers that are mapped in read/write mode, the
force( )
method outputs any changes that have been
made to the buffer contents to the underlying file. If the file is on
a local device, then it is guaranteed to be updated before
force( )
returns. No such guarantees can be made
for mapped network files.
Note that the underlying file of a
MappedByteBuffer
may be shared, which means that the contents of such a buffer can change asynchronously if the contents of the file are modified by another thread or another process (such asynchronous changes to the underlying file may or may not be visible through the buffer; this is a platform-dependent, and should not be relied on). Furthermore, if another thread or process truncates the file, some or all of the elements of the buffer may no longer map to any content of the file. An attempt to read or write such an inaccesible ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.