小言_互联网的博客

IO流插入修改

358人阅读  评论(0)
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
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场