How can I specify file deletion from directory deletion using JDK 7?

I am using JDK 7 WatchService to browse directories.

The event ENTRY_DELETEtells me that the record has been deleted. I can get the name of this entry, something similar to:

WatchEvent<Path> ev = cast(event);
Path name = ev.context();
Path child = dir.resolve(name);

I want to know if the remote record was a file or folder. Naturally, I tried child.isDirectory(), but it did not work, of course, because the element no longer exists.

Is there a way, without heuristic, to indicate if the deleted item was a file or directory?

+3
source share
1 answer

, WatchService , , . Linux inotify , , Microsoft FileSystemWatcher .

+1

Source: https://habr.com/ru/post/1753779/


All Articles