package com.tedu.day1201;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class CopyFile {
public static void main(String[] args) {
FileInputStream in= null;
FileOutputStream out =null;
String source = "test.txt";
String tar = "test3.txt";
try {
in = new FileInputStream(source);
out = new FileOutputStream(tar);
int data;
while ((data=in.read())!=-1){
out.write(data);
}
in.close();
out.close();
System.out.println("文件复制陈宫了");
}catch (Exception e){
e.printStackTrace();
}finally {
try {
in.close(); // 可能出现IOException
out.close();
}catch (Exception e){
e.printStackTrace();
}
}
}
}