title: Java monitoring multiple folders
body: <p>I need to monitor multiple folder and I want to khow which folder has received
   an event to execute a particular treatment. I've tried this code. </p>
  
  <pre><code>WatchService watchService = FileSystems.getDefault().newWatchService();
  opexFolder.register(watchService, StandardWatchEventKinds.ENTRY_CREATE);
  docupostFolder.register(watchService, StandardWatchEventKinds.ENTRY_CREATE);
  
      boolean valid = true;
      do {
          WatchKey watchKey = watchService.take();
          for (WatchEvent&lt;?&gt; event : watchKey.pollEvents()) {
              WatchEvent.Kind kind = event.kind();                
              if (StandardWatchEventKinds.ENTRY_CREATE.equals(event.kind())) {                    
                  String fileName = event.context().toString();                   
  
                  //here I want to khow the path of the folder that has 
                  // received the ENTRY event 
                 String pathToExplore = ??;
                if (pathToExplore has some value) {
                  treatments;
                } else {
                  other treatments;
                  }
  
              }
          }
          valid = watchKey.reset();
  
      } while (valid);
  }
  </code></pre>
  
  <p>Is it possible to do that, or I must to create watchService per folder.</p>
  
  <p>Thanks. </p>