com.vaadin.base.devserver.
Class FileWatcher
All Implemented Interfaces:
Watches for the file or sub-directory changes in the given directory.
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFileWatcher
(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.
FileWatcher
(SerializableConsumer<File> onChangeConsumer, File... watchDirectory) Creates an instance of the file watcher for the given directory.
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setTimeout
(long timeout) Sets the time interval between file/directory checks.
void
start()
Starts the file watching.
void
stop()
Stops the file watching.
void
stop
(long stopInterval) Stops the file watching and waits for a given stop interval for watching thread to finish.
-
Constructor Details
-
FileWatcher
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 detectedwatchDirectory
- 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 watchedonChangeConsumer
- to be called when any change detectedwatchDirectory
- 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 watchedlistener
- to be invoked once any changes detectedwatchDirectory
- the directory to watch for the changes, cannot be empty
-
-
Method Details
-
start
Starts the file watching.
Throws:
Exception
- if an error occurs during startup -
stop
Stops the file watching.
Throws:
Exception
- if an error occurs during stop -
stop
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 threadThrows:
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
-