MappedByteBuffer


MappedByteBuffer java.nio

Java 1.4 comparable

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 element of the buffer will cause an implementation-defined exception, either immediately or at some later time.

Figure 13-10. java.nio.MappedByteBuffer

 public abstract class  MappedByteBuffer  extends ByteBuffer {  // No Constructor   // Public Instance Methods  public final MappedByteBuffer  force  ( );        public final boolean  isLoaded  ( );        public final MappedByteBuffer  load  ( );   } 

Returned By

java.nio.channels.FileChannel.map( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net