3 ms·
> exact code to open a file, read each of the lines, and then close everything var lines = Files.lines(Paths.get("file.txt")); or if you want to be extrem
by vips7L 5y ago
> exact code to open a file, read each of the lines, and then close everything
var lines = Files.lines(Paths.get("file.txt"));
or if you want to be extremely cautious:
try (var lines = Files.lines(Paths.get("file.txt"))) {
}
I agree about IOException though. It's the bane of my existence :) The amount of times I have to rethrow UncheckedIOException is far too high.