Java缓冲字符读取

public class BufferedReaderDemo {
    public static void main(String[] args) throws IOException {
           // 创建流对象
        BufferedReader br = new BufferedReader(new FileReader("in.txt"));
        // 定义字符串,保存读取的一行文字
        String line  = null;
          // 循环读取,读取到最后返回null
        while ((line = br.readLine())!=null) {
            System.out.print(line);
            System.out.println("------");
        }
        // 释放资源
        br.close();
    }
}
忘了他,我撸代码养你
原文地址:https://www.cnblogs.com/theworld/p/11650124.html