Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

WatchService WatchKey.cancel() is really forever ?

2766010Oct 1 2014 — edited Nov 26 2014

I am using java 8 on linux ubuntu 12.04 following the guidelines Watching a Directory for Changes (The Java™ Tutorials > Essential Classes > Basic I/O)

This works but I notice that once I cancel a watchkey with watchkey.cancel() , I seem to be unable to reenable it again. So I can never watch a directory after I have cancelled the corresponding watchkey (even after reboot ) ?

The API Doc says that " Once cancelled, a watch key remains forever invalid."


What does "forever" mean ? There must be a way to re-watch a dir after the key has been cancelled.


Thanks for your help.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 24 2014
Added on Oct 1 2014
2 comments
1,426 views