BufferedReader的简单示例

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;


public class BufferedReaderDemo {

    public static void main(String[] args) throws IOException {

        FileReader fr=new FileReader("buf.txt");

        BufferedReader bufr=new BufferedReader(fr);

        //缓冲区读取可以读 [单个字符][字符数组][一行]
        String line=null;
        while((line=bufr.readLine())!=null){
            System.out.println(line);
        }
        bufr.close();
    }
}

你可能感兴趣的:(Link-IO)