1Path pathBattlesFolder = Paths.get("filepath");
2WatchService watchService = pathBattlesFolder.getFileSystem().newWatchService();
3pathBattlesFolder.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
4WatchKey watchKey = null;
5while(true){
6
7 watchKey = watchService.poll();
8 if (watchKey != null){
9 if (watchKey.pollEvents().size() > 0){
10 //if it gets here then something has been changed
11 }
12 watchKey.reset();
13 }
14
15}
16
17**watchKey.reset() should fix the problem.