Skip to content

java-io

5 Posts

How to Use WatchService in Java to Watch a Directory

Build a folder watcher in Java 21 with WatchService. It copes with half-written files, duplicate events and overflow, and ships with 23 passing checks.

How to Use ProcessBuilder to Run Commands in Java 21

How to use ProcessBuilder in Java 21: run a command, read stdout and stderr, feed stdin, set a timeout and kill a stuck child, with 14 checks and 5 traps.