Skip to content

Commit

Permalink
fix try with resources in day 21
Browse files Browse the repository at this point in the history
  • Loading branch information
ythirion committed Dec 26, 2023
1 parent b728ada commit 05227bd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions solution/day21/src/main/java/audit/Persister.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

public class Persister {
public FileContent[] readDirectory(String directory) throws IOException {
return Files.walk(Paths.get(directory))
.filter(Files::isRegularFile)
.map(Persister::readFile)
.toArray(FileContent[]::new);
try (var paths = Files.walk(Paths.get(directory))) {
return paths.filter(Files::isRegularFile)
.map(Persister::readFile)
.toArray(FileContent[]::new);
}
}

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

0 comments on commit 05227bd

Please sign in to comment.