@@ -0,0 +1,1855 @@
+package com.hzh.corejava.io;%0A%0Aimport java.nio.ByteBuffer;%0Aimport java.nio.channels.AsynchronousFileChannel;%0Aimport java.nio.channels.CompletionHandler;%0Aimport java.nio.file.Paths;%0Aimport java.nio.file.StandardOpenOption;%0Aimport java.util.EnumSet;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.ScheduledThreadPoolExecutor;%0Aimport java.util.concurrent.TimeUnit;%0A%0A/**%0A * Created by Adam on 2016/2/25.%0A */%0Apublic class AsynchronousReadWithCustomThreadPool %7B%0A    public static void main(String args%5B%5D) throws Exception %7B%0A        ExecutorService pool = new ScheduledThreadPoolExecutor(3);%0A        AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(%0A                Paths.get(%22test.txt%22), EnumSet.of(StandardOpenOption.READ),%0A                pool);%0A        CompletionHandler%3CInteger, ByteBuffer%3E handler = new CompletionHandler%3CInteger, ByteBuffer%3E() %7B%0A            @Override%0A            public synchronized void completed(Integer result, ByteBuffer attachment) %7B%0A                for (int i = 0; i %3C attachment.limit(); i++) %7B%0A                    System.out.println((char) attachment.get(i));%0A                %7D%0A            %7D%0A%0A            @Override%0A            public void failed(Throwable e, ByteBuffer attachment) %7B%0A            %7D%0A        %7D;%0A%0A        final int bufferCount = 5;%0A        ByteBuffer buffers%5B%5D = new ByteBuffer%5BbufferCount%5D;%0A        for (int i = 0; i %3C bufferCount; i++) %7B%0A            buffers%5Bi%5D = ByteBuffer.allocate(10);%0A            fileChannel.read(buffers%5Bi%5D, i * 10, buffers%5Bi%5D, handler);%0A        %7D%0A        pool.awaitTermination(1, TimeUnit.SECONDS);%0A        System.out.println(%22The file content is:%22);%0A        for (ByteBuffer byteBuffer : buffers) %7B%0A            for (int i = 0; i %3C byteBuffer.limit(); i++) %7B%0A                System.out.print((char) byteBuffer.get(i));%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add AsynchronousReadWithCustomThreadPool.java