Map FileChannel to MappedByteBuffer : MappedByteBuffer « File Input Output « Java

Map FileChannel to MappedByteBuffer


import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class Main {
  public static void main(String args[]) throws Exception {
    String filename = args[0];
    int start = 10;
    int length = 20;

    FileInputStream fin = new FileInputStream(filename);
    FileChannel finc = fin.getChannel();
    MappedByteBuffer mbb =, start, length);

    for (int i = 0; i < length; ++i) {


Related examples in the same category

1.Persisting Changes to a Memory-Mapped ByteBuffer
2.Read file upside/down with RandomAccessFile
3.Use a mapped file to read a text file.