You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.base.devserver.

Class FileWatcher

java.lang.Object
com.vaadin.base.devserver.FileWatcher

All Implemented Interfaces:

Serializable

public class FileWatcher extends Object implements Serializable

Watches for the file or sub-directory changes in the given directory.

See Also:

  • Constructor Details

    • FileWatcher

      public FileWatcher(SerializableConsumer<File> onChangeConsumer, File... watchDirectory)

      Creates an instance of the file watcher for the given directory.

      Reports the changed file or directory as a File instance to the provided consumer.

      Watches the files create/delete and directory create/delete events.

      Parameters:

      onChangeConsumer - to be called when any change detected

      watchDirectory - the directory to watch for the changes, cannot be empty

    • FileWatcher

      public FileWatcher(SerializableConsumer<File> onChangeConsumer, SerializablePredicate<File> fileFilter, File... watchDirectory)

      Creates an instance of the file watcher for the given directory taking into account the given file filter.

      Reports the changed file or directory as a File instance to the provided consumer.

      Watches the files create/delete and directory create/delete events.

      Parameters:

      fileFilter - defined if the given file or directory should be watched

      onChangeConsumer - to be called when any change detected

      watchDirectory - the directory to watch for the changes, cannot be empty

    • FileWatcher

      public FileWatcher(org.apache.commons.io.monitor.FileAlterationListener listener, SerializablePredicate<File> fileFilter, File... watchDirectory)

      Creates an instance of the file watcher for the given directory taking into account the given file filter.

      Reports the changed file or directory as a File instance to the provided consumer.

      Reports file and directory changes to the given listener.

      Parameters:

      fileFilter - defined if the given file or directory should be watched

      listener - to be invoked once any changes detected

      watchDirectory - the directory to watch for the changes, cannot be empty

  • Method Details

    • start

      public void start() throws Exception

      Starts the file watching.

      Throws:

      Exception - if an error occurs during startup

    • stop

      public void stop() throws Exception

      Stops the file watching.

      Throws:

      Exception - if an error occurs during stop

    • stop

      public void stop(long stopInterval) throws Exception

      Stops the file watching and waits for a given stop interval for watching thread to finish.

      Parameters:

      stopInterval - time interval to wait for the watching thread

      Throws:

      Exception - if an error occurs during stop

    • setTimeout

      public void setTimeout(long timeout)

      Sets the time interval between file/directory checks.

      Parameters:

      timeout - time interval between file/directory checks