r/learnprogramming • u/[deleted] • 16h ago
Question about Files.lines() with try-with-resources in Java
[deleted]
1
Upvotes
2
u/GeorgeFranklyMathnet 16h ago
You're right to use try-with-resources on a file I/O stream, says Baeldung and other reliable sources.
1
u/andyflip 15h ago
If you wanted to be super explicit, you could release the resources in a finally {} after the catch.