Java MappedByteBuffer read
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);/*www. ja va 2s. c o m*/ while (mbb.hasRemaining()) { System.out.print((char) mbb.get()); } fc.close(); fis.close(); } }