Java MappedByteBuffer create from FileChannel
import java.io.FileInputStream; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; public class Main { public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream("Main.java"); FileChannel fc = fis.getChannel(); long startRegion = 0; long endRegion = fc.size(); MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, startRegion, endRegion);// w ww. j av a 2s . c o m while (mbb.hasRemaining()) { System.out.print((char) mbb.get()); } fc.close(); fis.close(); } }