Question

I can't reproduce the issue in a minor example, but is it possible to register two different WatchKeys for one Path if the WatchService and the Kind<?>s are the same?

For instance if the parent-directory content changes?

Était-ce utile?

La solution

Yes it is, if you cancel the old one before registering the second one.

Due to the fact, that pending events, if any, remain pending and may be retrieved by invoking the pollEvents method after the key is cancelled, this seems to be reasonable.

The cancelled WatchKey stays invalid forever though.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top