I am trying to monitor a remote folder using WatchService (java.nio.file.*). Everything works fine for local folders. However I was unable to figure out how to monitor a remote share. Can I pass credentials along?
(If the user executing the code has the rights to mount the share it works as well.)
Here are parts of my code:
  public void lunch() throws IOException {
        boolean recursive = true;
        Path dir = Paths.get("C:\\test");
        new Watch(dir, recursive).processEvents();
    }
    public Watch(Path dir, boolean recursive) throws IOException {
        this.watcher = FileSystems.getDefault().newWatchService();
        this.keys = new HashMap<WatchKey,Path>();
        this.recursive = recursive;
        if (recursive) {
            System.out.format("Scanning %s ...\n", dir);
            registerAll(dir);
            System.out.println("Done.");
        } else {
            register(dir);
        }
}
Cheers, Stephanie