Skip to content

Commit 05227bd

Browse files
committed
fix try with resources in day 21
1 parent b728ada commit 05227bd

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

solution/day21/src/main/java/audit/Persister.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
public class Persister {
1010
public FileContent[] readDirectory(String directory) throws IOException {
11-
return Files.walk(Paths.get(directory))
12-
.filter(Files::isRegularFile)
13-
.map(Persister::readFile)
14-
.toArray(FileContent[]::new);
11+
try (var paths = Files.walk(Paths.get(directory))) {
12+
return paths.filter(Files::isRegularFile)
13+
.map(Persister::readFile)
14+
.toArray(FileContent[]::new);
15+
}
1516
}
1617

1718
public void applyUpdate(String directory, FileUpdate update) throws IOException {

0 commit comments

Comments
 (0)