watch service does not detect more than one poll java
Path pathBattlesFolder = Paths.get("filepath");
WatchService watchService = pathBattlesFolder.getFileSystem().newWatchService();
pathBattlesFolder.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
WatchKey watchKey = null;
while(true){
watchKey = watchService.poll();
if (watchKey != null){
if (watchKey.pollEvents().size() > 0){
//if it gets here then something has been changed
}
watchKey.reset();
}
}
**watchKey.reset() should fix the problem.