美文网首页
JavaSE BufferReaderDemo

JavaSE BufferReaderDemo

作者: 23b57d72cde7 | 来源:发表于2018-04-16 19:21 被阅读0次
package com.sxt;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * 缓存字符流
 * 
 * @author Administrator
 *
 */
public class BufferReaderDemo {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("c:/aaa.txt"));
        String s = "";
        while ((s = br.readLine()) != null) {
            System.out.println(s);
        }
        br.close();
        BufferedWriter bw = new BufferedWriter(new FileWriter("c:/a.txt"));
        bw.write("我是王二");
        bw.newLine();
        bw.write("我今年20岁");
        bw.close();
    }
}

相关文章

网友评论

      本文标题:JavaSE BufferReaderDemo

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