org.springframework.boot.devtools.filewatch

Class FileSystemWatcher

  • java.lang.Object
    • org.springframework.boot.devtools.filewatch.FileSystemWatcher


  • public class FileSystemWatcher
    extends Object
    Watches specific folders for file changes.
    Since:
    1.3.0
    Author:
    Andy Clement, Phillip Webb
    See Also:
    FileChangeListener
    • Constructor Detail

      • FileSystemWatcher

        public FileSystemWatcher()
        Create a new FileSystemWatcher instance.
      • FileSystemWatcher

        public FileSystemWatcher(boolean daemon,
                                 Duration pollInterval,
                                 Duration quietPeriod)
        Create a new FileSystemWatcher instance.
        Parameters:
        daemon - if a daemon thread used to monitor changes
        pollInterval - the amount of time to wait between checking for changes
        quietPeriod - the amount of time required after a change has been detected to ensure that updates have completed
    • Method Detail

      • addListener

        public void addListener(FileChangeListener fileChangeListener)
        Add listener for file change events. Cannot be called after the watcher has been started.
        Parameters:
        fileChangeListener - the listener to add
      • addSourceFolders

        public void addSourceFolders(Iterable<File> folders)
        Add source folders to monitor. Cannot be called after the watcher has been started.
        Parameters:
        folders - the folders to monitor
      • addSourceFolder

        public void addSourceFolder(File folder)
        Add a source folder to monitor. Cannot be called after the watcher has been started.
        Parameters:
        folder - the folder to monitor
      • setTriggerFilter

        public void setTriggerFilter(FileFilter triggerFilter)
        Set an optional FileFilter used to limit the files that trigger a change.
        Parameters:
        triggerFilter - a trigger filter or null
      • start

        public void start()
        Start monitoring the source folder for changes.
      • stop

        public void stop()
        Stop monitoring the source folders.