Java WatchService not generating events while watching mapped drives

后端 未结 5 1846
春和景丽
春和景丽 2020-11-30 05:58

I implemented a file watcher but I noticed that java nio file watcher doesn\'t generate events for files being copied on mapped drives. For instance, I\'ve run the file watc

5条回答
  •  没有蜡笔的小新
    2020-11-30 06:11

    File watching functionality in JDK is platform dependent as it uses native libraries so it could behave differently on different platform. I'm surprised it works for network drives at all - Windows must be polling network mapped drives for changes while Linux doesn't (rightfully so I should say).

    Usually this sort of monitoring implemented in OS kernel, which obviously has knowledge which files are modified/created/etc locally but there are no easy ways for OS to know what happening on network drive as it doesn't have exclusive control over it.

提交回复
热议问题