Registers the file located by this path with a watch service.
In this release, this path locates a directory that exists. The directory is registered with the watch service so that entries in the directory can be watched. The {@code events} parameter is the events toregister and may contain the following events:
- {@link StandardWatchEventKinds#ENTRY_CREATE ENTRY_CREATE} -entry created or moved into the directory
- {@link StandardWatchEventKinds#ENTRY_DELETE ENTRY_DELETE} -entry deleted or moved out of the directory
- {@link StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} -entry in directory was modified
The {@link WatchEvent#context context} for these events is therelative path between the directory located by this path, and the path that locates the directory entry that is created, deleted, or modified.
The set of events may include additional implementation specific event that are not defined by the enum {@link StandardWatchEventKinds}
The {@code modifiers} parameter specifies modifiers thatqualify how the directory is registered. This release does not define any standard modifiers. It may contain implementation specific modifiers.
Where a file is registered with a watch service by means of a symbolic link then it is implementation specific if the watch continues to depend on the existence of the symbolic link after it is registered.
@param watcher the watch service to which this object is to be registered
@param events the events for which this object should be registered
@param modifiers the modifiers, if any, that modify how the object is registered
@return a key representing the registration of this object with thegiven watch service
@throws UnsupportedOperationException if unsupported events or modifiers are specified
@throws IllegalArgumentException if an invalid combination of events or modifiers is specified
@throws ClosedWatchServiceException if the watch service is closed
@throws NotDirectoryException if the file is registered to watch the entries in a directory and the file is not a directory (optional specific exception)
@throws IOException if an I/O error occurs
@throws SecurityException In the case of the default provider, and a security manager is installed, the {@link SecurityManager#checkRead(String) checkRead}method is invoked to check read access to the file.