public static void main(String[] args) throws IOException {
File file=new File("C:\\Users\\Desktop\\AAA.txt");
FileInputStream fis=new FileInputStream(file);//原文件
FileOutputStream fos=new FileOutputStream(".//des.txt");//目标文件
FileChannel fc=fis.getChannel();//获得原文件的通道
FileChannel des=fos.getChannel();//目标文件的通道
fc.transferTo(0,fc.size() , des); //连接通道,从fc通道读取,写入到des通道。
//关闭流操作
fc.close();
des.close();
fis.close();
File file=new File("C:\\Users\\Desktop\\AAA.txt");
FileInputStream fis=new FileInputStream(file);//原文件
FileOutputStream fos=new FileOutputStream(".//des.txt");//目标文件
FileChannel fc=fis.getChannel();//获得原文件的通道
FileChannel des=fos.getChannel();//目标文件的通道
fc.transferTo(0,fc.size() , des); //连接通道,从fc通道读取,写入到des通道。
//关闭流操作
fc.close();
des.close();
fis.close();
fos.close();