Java: File Renaming Detection

后端 未结 3 1651
有刺的猬
有刺的猬 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:41

    Take a look at jpathwatch. In addition to the standard watch event kinds specified in Java 7 (ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY) it also has additional events called ENTRY_RENAME_FROM and ENTRY_RENAME_TO which will fire when a file is renamed. Note that this depends on whether the underlying operating system supports file renaming events or not.

提交回复
热议问题