try-with-resources auto-closes the reader
try-with-resources auto-closes the reader
Answer
try (BufferedReader in = new BufferedReader(new FileReader("examples1.txt"))) { System.out.println(in.readLine()); }
The reader implements `AutoCloseable`, so `in.close()` is called automatically when the block ends — even if `readLine()` throws.