![](/img/trans.png)
[英]Java WatchService does not report files when the parent directory is deleted
[英]Java WatchService for already existing files in directory
我有一個WatchService實現,其中服務使用key = watchService.poll()
或take()
方法監視目錄。但是我面臨的問題是,如果在開始poll()
之前已經有一些文件存在於watch目錄中,該怎么辦? poll()
或take()
方法。 WatchService無法跟蹤那些。 如何在目錄下獲取這些文件? WatchService提供了什么來實現這一目標? 或其他解決方案來應對這一挑戰?
提前致謝!
您可以在啟動服務之前使用listFiles方法,並且獲得正確的文件名嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.