FileChannel: map(MapMode mode, long position, long size)

abstract MappedByteBuffer map(FileChannel.MapMode mode, long position, long size)
Maps a region of this channel's file directly into memory.
 
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.IntBuffer;
import java.nio.channels.FileChannel;

public class Main {
  public static void main(String[] args) throws IOException {
    FileChannel fc = new RandomAccessFile(new File("temp.tmp"), "rw").getChannel();
    IntBuffer ib = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size()).asIntBuffer();
    ib.put(0);
    for (int i = 1; i < 10; i++)
      ib.put(ib.get(i - 1));
    fc.close();

  }
}
  
Home 
  Java Book 
    File Stream  

FileChannel:
  1. FileChannel
  2. FileChannel.MapMode.READ_WRITE
  3. FileChannel: close()
  4. FileChannel: lock(long position, long size, boolean shared)
  5. FileChannel: map(MapMode mode, long position, long size)
  6. FileChannel: position()
  7. FileChannel: position(long newPosition)
  8. FileChannel: read(ByteBuffer dst)
  9. FileChannel: size()
  10. FileChannel: transferFrom(ReadableByteChannel src, long position, long count)
  11. FileChannel: transferTo(long position, long count, WritableByteChannel target)
  12. FileChannel: tryLock()
  13. FileChannel: write(MappedByteBuffer buffer)