JavaSE BufferReaderDemo

2018-04-16  本文已影响0人  23b57d72cde7
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();
    }
}
上一篇 下一篇

猜你喜欢

热点阅读