Suggestions/sample code for fileSystemWatcher in Java

后端 未结 5 542
[愿得一人]
[愿得一人] 2021-01-02 14:27

I am trying to build a fileSystemWatcher in java (similar to FileSystemWatcher in C#). Please suggest whether java has any built in framework capability for this or suggest/

相关标签:
5条回答
  • 2021-01-02 14:39

    I don't believe there's any inbuilt capability. You can always poll the directory in a thread, and watch for directory modification times etc. That's trivial, but I'm not sure how OSes differ in how they'll reflect directory changes in the directory meta data. If you have to keep track of a directory with a large number of files, any solutions based on polling may be quite heavyweight.

    I note this, which is a more optimal version for Windows (not that I know what platform you're on!)

    0 讨论(0)
  • 2021-01-02 14:41

    it's more better choice http://jnotify.sourceforge.net/

    0 讨论(0)
  • 2021-01-02 14:56

    "More NIO Features" in JDK7 should have a cross-platform version of such a facility (taking advantage of particular platform capabilities on any reasonable JRE implementation).

    0 讨论(0)
  • 2021-01-02 15:00

    Check out the Apache Commons JCI FAM (FileAlterationMonitor). The unit tests should give you an idea how to use it.

    0 讨论(0)
  • 2021-01-02 15:02

    http://www2.hawaii.edu/~qzhang/FileSystemWatcher.html

    0 讨论(0)
提交回复
热议问题