Here you can find the source of toMappedBuffer(File file, long start, long end)
public static ByteBuffer toMappedBuffer(File file, long start, long end) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class Main { public static ByteBuffer toMappedBuffer(File file, long start, long end) throws IOException { try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { return raf.getChannel().map(FileChannel.MapMode.READ_ONLY, start, end); }//from w w w . j av a2s .c o m } }