public void run() {
try(WatchService service = FileSystems.getDefault().newWatchService()){
Path path = Paths.get("C:\\logs");
path.register(service, ENTRY_MODIFY);
WatchKey watchKey;
do {
watchKey = service.take();
if (watchKey.pollEvents() != null) {
System.out.println("changed");
}
}while (watchKey.reset());
}catch (Exception e){
System.out.println(e);
}
}
Спасибо