zuoye

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();
}
}
}

上一篇:【Educational Codeforces Round 74 (Rated for Div. 2) C 】Standard Free2play


下一篇:IO--输入输出流和字符流