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 and then ENTRY_CREATE.
Is there a way to detect file renaming using Java? (NIO’s WatchService API or
Share
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 calledENTRY_RENAME_FROMandENTRY_RENAME_TOwhich will fire when a file is renamed. Note that this depends on whether the underlying operating system supports file renaming events or not.