title: Check whether a directory is registered to any watcher service?
body: <p>As part of my application, I need to register multiple directories to watcher service. Whenever there is a change in the directory, I will get notified by watcher service. My requirement is, for a given directory, is there any way to know, whether that directory is registered to any watcher service? I mean, I </p>
  
  <pre><code>Path path = new File("/Users/myDoc").toPath();
  WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
  
  public static boolean isDirectoryRegisteredToAnyWatcherService(Path path){
      //Return true, if this directory is registered to any watcher service, else false.
  }
  </code></pre>
  
  <p>Reference</p>
  
  <p><a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/WatchService.html" rel="nofollow">https://docs.oracle.com/javase/7/docs/api/java/nio/file/WatchService.html</a></p>