Search code examples
javamonitoringfilesystemwatcher

monitoring directory on another pc


I want to monitor a folder located on another computer using the FileSystemWatcher.

How can i do that?


Solution

  • Suppose, your computer A wants to observe a directory on the hard drive of computer B. Here are some ways to achieve this:

    • Have computer A mount the remote file system on B using SMB, NFS or some other network file system protocol. Then your application running on A should be able to:

      • use a Java 7 WatchService to get file system events on the directory,

      • in Java 6 and earlier, poll the directory's modification date etc to see when it changes, or

      • use a native program or library to read Linux inotify(7) events or the Windows equivalent.

    • If you can't mount B's file system on A, you need to implement and run some kind of remote service on B that can be queried by a client application running on A. There are many possible ways to do this.