package Week5ClassFir;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class DemoCopyFile {
public static void main(String[] args) {
File file=new File("D:\\chong\\cym.txt");//文件-地址是pathname
File newfile=new File("D:\\chong\\sym.txt");
try {
@SuppressWarnings("resource")
FileInputStream fileInputStream=new FileInputStream(file);
if (newfile.createNewFile()){
FileOutputStream fileOutputStream=new FileOutputStream(newfile);
int x=0;
while ((x=fileInputStream.read())!=-1){
fileOutputStream.write(x);
}
}
}catch (Exception E){
E.printStackTrace();
}
}
}