package chapter7;

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

public class Example10 {
    public static void main(String[] args) {
        // 使用try-with-resources自动关闭资源
        try (BufferedReader reader = new BufferedReader(
                new FileReader("note.txt"))) {

            String line;
            // 逐行读取文件内容
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }

        } catch (IOException e) {
            System.out.println("读取文件出错：" + e.getMessage());
        }
    }
}