美文网首页
2021-08-28 IO流(通过缓冲区复制文本文件)

2021-08-28 IO流(通过缓冲区复制文本文件)

作者: Denholm | 来源:发表于2021-09-18 15:30 被阅读0次
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileReader;
    import java.io.FileWriter;
    
    // 通过缓冲区赋值文件
    public class CopyTextByBuf {
    
        public static void main(String[] args) throws Exception {
            BufferedReader bufferedReader = new BufferedReader(
                    new FileReader("E:\\index_banner.ftl"));
            BufferedWriter bufferedWriter = new BufferedWriter(
                    new FileWriter("F:\\index_banner_copy.ftl"));
    
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                bufferedWriter.write(line);
                bufferedWriter.newLine();
            }
            bufferedWriter.flush();
    
            bufferedWriter.close();
            bufferedReader.close();
        }
    
    }
    
    readLine的原理图例

    相关文章

      网友评论

          本文标题:2021-08-28 IO流(通过缓冲区复制文本文件)

          本文链接:https://www.haomeiwen.com/subject/gkyiiltx.html