我使用这里的技术,并在70秒内将两个1.5GB文件连接起来。
http://nadeausoftware.com/articles/2008/02/java_tip_how_read_files_quickly
我的代码使用了FileChannels、内存映射和8KB缓冲区大小的ByteBuffers。
我该如何提高速度?
File file = new File(binDirectory + "/donjon.avi");
File oFile = new File(binDirectory + "/donjon2.avi");
FileInputStream is = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(oFile);
FileChannel f1 = is.getChannel();
FileChannel f2 = fos.getChannel();
f2.transferFrom(f1, 0, f1.size());
f2.transferFrom(f1, f1.size(), f1.size());
f2.close();
f1.close();