Java: File Renaming Detection

后端 未结 3 1652
有刺的猬
有刺的猬 2020-12-03 23:17

Is there a way to detect file renaming using Java? (NIO\'s WatchService API or any other) From what I\'ve seen when renaming a file two separate events occur - ENTRY_DELETE

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 23:57

    Detecting renaming of files can not be done portably. Because, surprising as it may seem, the idea that a file HAS-A name is not portable. Most Unix file systems allow a file to have any number of ASSOCIATED names (including zero names). In the Unix (POSIX) world, renaming means adding a new name and then removing the original name.

提交回复
热议问题