try-with-resources opens resources in the parentheses of the try: they must implement AutoCloseable and are closed automatically on leaving the block, even on exception, in the reverse order of their opening. It replaces the manual finally for files and connections.
Example
try (var in = Files.newBufferedReader(chemin)) {
return in.readLine();
}