package 练习11号; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class CopyText { public static void main(String[] args) throws IOException{ copy_1(); } public static void copy_1() throws IOException{ FileWriter fw=new FileWriter("zhangxn.txt"); FileReader fr=new FileReader("demo.txt"); int ch; while((ch=fr.read())!=-1){ fw.write(ch); } fw.close(); fr.close(); } }
输出结果: