package Inheritance;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class ccc {
public static void main(String[] args) throws IOException {
FileWriter f = new FileWriter(new File("C:\\Users\\23910\\Desktop\\Hello.txt"));
char[] a = "HellowJavaWorld".toCharArray();
f.write(a);
f.flush();
f.close();
FileReader r=new FileReader(new File("C:\\Users\\23910\\Desktop\\Hello.txt"));
FileWriter in =new FileWriter(new File("C:\\Users\\23910\\Desktop\\备份.txt"));
int i =0;
while ( (i=r.read(a,0,a.length)) !=-1 ){
in.write(a);
in.flush();
}
r.close();
in.close();
}
}
转载:https://blog.csdn.net/qq_43618953/article/details/101537637
查看评论