Here you can find the source of getReadBuffer(File file)
public static ByteBuffer getReadBuffer(File file)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.*; import java.nio.channels.FileChannel.MapMode; public class Main { public static ByteBuffer getReadBuffer(File file) { try (RandomAccessFile f = new RandomAccessFile(file, "r")) { return f.getChannel().map(MapMode.READ_ONLY, 0, file.length()); } catch (IOException e) { return null; }/* w w w.j ava 2s .c o m*/ } public static ByteBuffer getReadBuffer(String file) { return getReadBuffer(new File(file)); } }