package net.cw.lesson11;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
-
功能:利用文件读写完成文件复制工作
-
作者:巍巍妹纸
-
日期:2019年5月23日
*/
public class FileCopy {
public static void main(String[] args) {
File file1 = new File(“c:/scenery01.jpg”);
File file2 = new File(“d:/scenery02.jpg”);try { FileInputStream fis = new FileInputStream(file1); FileOutputStream fos = new FileOutputStream(file2); byte[] b = new byte[1024]; while (fis.read(b) != -1){ fos.write(b); } System.out.println("文件[" + file1.getPath() + "成功复制到文件[" + file2.getPath() + "]."); } catch (IOException e) { e.printStackTrace(); }
}
}