java 从一个文件中读取内容 复制到 另一个文件中

    xiaoxiao2021-12-14  20

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

    输出结果:

    转载请注明原文地址: https://ju.6miu.com/read-970923.html

    最新回复(0)