ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
//Direct Buffer的效率会更高。
// ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024);
long start = System.currentTimeMillis();
while(true)
{
int eof = inChannel.read(byteBuffer);
if(eof == -1 ) break;
byteBuffer.flip();
outChannel.write(byteBuffer);
byteBuffer.clear();
}
System.out.println("spending : " + (System.currentTimeMillis()-start));
inChannel.close();
outChannel.close();
}