Class DirectoryWatcher.ChangeListener

  • Enclosing class:
    DirectoryWatcher

    public class DirectoryWatcher.ChangeListener
    extends Object
    A change listener for a single directory that can be used to register notification callbacks and to cancel observing this directory.
    • Method Detail

      • cancel

        public void cancel()
        Cancels this change listener.
      • onChange

        public DirectoryWatcher.ChangeListener onChange​(BiConsumer<Path,​WatchEvent.Kind<Path>> consumer)
        Registers a listener to be notified of change events for this directory.
        Parameters:
        consumer - the callback that will be given the normalized absolute path of the file that changed and the kind of change event.
        Returns:
        this change listener.
      • onOverflow

        public DirectoryWatcher.ChangeListener onOverflow​(Runnable action)
        Registers a callback to be notified when the underlying watch service lost some change events due to overflow.
        Parameters:
        action - the action to perform when the watch service loses events due to overflow.
        Returns:
        this change listener.