Package name.pachler.nio.file
Interface Watchable
-
public interface WatchableA watchable is an object that can be registered with aWatchServiceto be monitored for changes via it'sregistermethods. The watchable only defines an interface, usePathto actually watch directories.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description WatchKeyregister(WatchService watcher, WatchEvent.Kind<?>... events)Registers the file system path (a directory) with the given WatchService and provides a WatchKey as a handle for that registration.WatchKeyregister(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)Registers the file system path (a directory) with the givenWatchServiceand provides a WatchKey as a handle for that registration.
-
-
-
Method Detail
-
register
WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws java.io.IOException
Registers the file system path (a directory) with the given WatchService and provides a WatchKey as a handle for that registration. Equivalent to callingregister(watcher, events, new WatchEvent.Modifier[0]);- Throws:
java.io.IOException- See Also:
Path#register(name.pachler.nio.file.WatchService, name.pachler.nio.file.WatchEvent.Kind>[], name.pachler.nio.file.WatchEvent.Modifier[])
-
register
WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws java.io.IOException
Registers the file system path (a directory) with the givenWatchServiceand provides a WatchKey as a handle for that registration. The events and modifier lists determine the events that theWatchServicewill report.
If a path instance is passed in that represents the same file system object that has been specified in a previous call to this method with the sameWatchService, the sameWatchKeywill be returned. In this case, theWatchKey's watch settings are altered to match the new event and modifier lists. Note that such changes may result inStandardWatchEventKind.OVERFLOWevents to be reported on some platforms.
Not all event kinds and modifiers defined inStandardWatchEventKind,ExtendedWatchEventKindandExtendedWatchEventModifiermay be supported on a target platform (typically though, in this implementation, all event kinds defined inStandardWatchEventKindare always supported).- Parameters:
watcher- a validWatchServiceinstance.events- The events to register for. The event kinds defined inStandardWatchEventKindandExtendedWatchEventKinddefine valid event kinds that can be passed in here. Not that not all event kinds may be supported on a given platform, so see the documentation of a specific event kind.modifiers- The event modifiers to use when registering.WatchEvent$Modifiers define special behaviour that's expected from theWatchService. Note that some event modifiers may not be supported on a given platform; see the specific modifier for details.- Returns:
- a new
WatchKeythat represents the registration. - Throws:
java.lang.UnsupportedOperationException- If unsupported event kinds have been providedjava.lang.IllegalArgumentException- If an unsupported combination of event kinds has been providedClosedWatchServiceException- If the given WatchService is already closed.NotDirectoryException- If a directory is required for the given registration options (which is typically the case) and the path instance does not reference a directoryjava.io.IOException- for general I/O errors- See Also:
StandardWatchEventKind,ExtendedWatchEventKind,ExtendedWatchEventModifier
-
-