我正在寻找一种在将路径注册到 WatchService 时传递参数的方法。目标是在处理与路径相关的事件时获取这些参数。
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
知道是否可能吗?
谢谢,米凯尔