67,512
社区成员
发帖
与我相关
我的任务
分享
//nio文件复制功能
public static void nioCopy(String infile, String outfile) throws Exception {
FileInputStream fin = new FileInputStream(infile);
FileOutputStream fout = new FileOutputStream(outfile);
FileChannel fcin = fin.getChannel();
FileChannel fcout = fout.getChannel();
//运行到这里就报错了
MappedByteBuffer mbb = fcin.map(FileChannel.MapMode.READ_ONLY, 0, fcin.size());
fcout.write(mbb);
fcin.close();
fcout.close();
fin.close();
fout.close();
}