[Java]把02.txt中的内容写入到05.txt中
//把02.txt中的内容写入到05.txt中 import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class Backup { public static void main(String[] args) throws IOException { FileReader in = new FileReader("02.txt"); FileWriter out = new FileWriter("05.txt"); int ch = in.read(); //.read()每次读取一个字符的ASCII值,如果读到结尾,返回-1 while (ch != -1) { out.write(ch); ch = in.read(); } in.close(); out.close(); } }