Java MappedByteBuffer.load()

Syntax

MappedByteBuffer.load() has the following syntax.

public final MappedByteBuffer load()

Example

In the following code shows how to use MappedByteBuffer.load() method.


import java.io.File;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
/*from w  ww.j av  a2s  .  c o m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    File file = new File("filename");
    FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
    MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_WRITE, 0, (int) channel.size());

    buf.put(0, (byte) 0xFF);

    System.out.println(buf.isLoaded());
    
    buf.force();
    
    MappedByteBuffer mbb = buf.load();

    channel.close();
  }
}




















Home »
  Java Tutorial »
    java.nio »




Buffer
ByteBuffer
ByteOrder
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
MappedByteBuffer
ShortBuffer