Retrieve each pending event for the key (there might be multiple events) and process as needed.You can obtain the file name from the key. Retrieve the key from the watcher's queue.When an event occurs, the key is signaled and placed into the watcher's queue. Implement an infinite loop to wait for incoming events.You receive a WatchKey instance for each directory that you register. When registering a directory, you specify the type of events for which you want notification. For each directory that you want monitored, register it with the watcher.Create a WatchService "watcher" for the file system.Here are the basic steps required to implement a watch service: You can use it as is, or you can choose to create a high-level API on top of this mechanism so that it is suited to your particular needs. The WatchService API is fairly low level, allowing you to customize it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |