code: private void registerFolder(final Path folder) throws IOException {
          // register directory and sub-directories
          Files.walkFileTree(folder, new SimpleFileVisitor<Path>() {
              @Override
              public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                      throws IOException
              {
                  WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
                  logger.debug("registering folder {}", dir);
                  folders.put(key, dir);
                  return FileVisitResult.CONTINUE;
              }
          });
      }
docs: Register the given directory, and all its sub-directories, with the
  WatchService.