It automatically closes resources that implement `AutoCloseable` (files, streams, JDBC) even when exceptions happen. It prevents leaks and keeps cleanup logic reliable and simple.
try (var in = Files.newInputStream(path)) {
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
}