How can I watch subdirectory for changes with WatchService? (Java)

后端 未结 2 2162
花落未央
花落未央 2020-12-31 15:49

I want to watch some directory for changes and her subdirectories. I tried to do this with WatchService but I can\'t know from which directory the file was changed. How can

2条回答
  •  甜味超标
    2020-12-31 16:33

    For users who use Spring:

    With Spring 4.2 WatchServiceDirectoryScanner is introduced. Now it can also catch sub directory changes.

    For more information, Javadocs on WatchServiceDirectoryScanner

提交回复
热议问题