Skip to content

Commit c9a754f

Browse files
author
eugenp
committed
cleanup resources
1 parent 8bf825d commit c9a754f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎core-java/src/main/java/com/baeldung/java/nio2/watcher/DirectoryWatcherExample.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.nio.file.WatchService;
1111

1212
public class DirectoryWatcherExample {
13+
1314
public static void main(String[] args) throws IOException, InterruptedException {
1415
WatchService watchService = FileSystems.getDefault().newWatchService();
1516
Path path = Paths.get(System.getProperty("user.home"));
@@ -21,5 +22,8 @@ public static void main(String[] args) throws IOException, InterruptedException
2122
}
2223
key.reset();
2324
}
25+
26+
watchService.close();
2427
}
28+
2529
}

0 commit comments

Comments
 (0)