I'm looking for a way to pass parameters when registering a Path to a WatchService. The goal is to get those parameters when processing events related to the Path.
WatchService watchService = FileSystems.getDefault().newWatchService();
....
path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE); //I would like to pass some parameters here...
....
key = watchService.take(); // ... so that I can get these parameters here from the WatchKey
Any idea if it is possible?
Thanks, Mickael
I just found that the
WatchKey
returned at registration is the same as the one returned by thetake()/poll()
method.I managed to solve it by maintaining an external
Map<WatchKey, ....>
.