Skip to content
Advertisement

Tag: watchservice

Java WatchService locks directory on Windows

It seems when you watch a directory using Java’s WatchService and then try to rename its parent directory, the renaming will fail with an AccessDeniedException. The directory seems to be sort of locked by the WatchService. Can be reproduced with: Fails with: Tested with OpenJDK 11 & 14 on Windows 10. Trying to rename dir1 in Windows Explorer also fails.

Using WatchService in JAVA. Can I watch subdirectory at the same time?

In JAVA I will watch directory by using WatchService. For example if I watch /users/monitor, WatchService can watch only one directory. But I wanna watch every subdirectory ‘at the same time’ How can I code? T_T —————————code——————————- —————————code——————————- Answer You can register multiple directories to the same directory watcher. Depending upon how the sub directory is created. If the directory

Advertisement