标签:
Path path_from= Paths.get("d:\\深入剖析.pdf");
Path path_to=Paths.get("d:\\深入剖析123.pdf");
long startTime,endtime;
try {
FileChannel fileChannel_from=FileChannel.open(path_from, EnumSet.of(StandardOpenOption.READ));
FileChannel fileChannel_to=FileChannel.open(path_to, EnumSet.of(StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE));
startTime=System.currentTimeMillis();
ByteBuffer byteBuffer=ByteBuffer.allocate(2048);
int b;
while ((b=fileChannel_from.read(byteBuffer))>0) {
byteBuffer.flip();
fileChannel_to.write(byteBuffer);
byteBuffer.clear();
}
endtime=System.currentTimeMillis()-startTime;
System.out.println(endtime);
} catch (Exception e) {
e.printStackTrace();
}
标签:
原文地址:http://my.oschina.net/u/1457061/blog/470343