!7 import java.nio.file.*; import static java.nio.file.StandardWatchEventKinds.*; p { File dir = programDir(); deleteAllProgramFiles(); makeProgramDir(); final Path path = dir.toPath(); WatchService watchService = FileSystems.getDefault().newWatchService(); final WatchKey watchKey = path.register(watchService, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY, OVERFLOW); thread { sleepSeconds(2); saveProgramTextFile("bla", "1"); } while licensed { final WatchKey wk = watchService.take(); print("Key taken"); for (WatchEvent event : wk.pollEvents()) pcall { final Path changed = (Path) event.context(); print("Changed: " + changed); } bool valid = wk.reset(); if (!valid) print("Key has been unregistered"); } }