Class FileWatcher

java.lang.Object
dev.engine.core.asset.FileWatcher

public class FileWatcher extends Object
Watches a directory for file modifications and dispatches callbacks. Uses the JDK WatchService on a daemon thread.
  • Constructor Details

    • FileWatcher

      public FileWatcher(Path directory)
  • Method Details

    • start

      public void start()
      Starts watching the directory for MODIFY events on a daemon thread.
    • addListener

      public void addListener(String path, Runnable callback)
      Registers a callback for when the given file path is modified. The path should be relative to the watched directory, or an absolute path.
    • stop

      public void stop()
      Stops the file watcher and its daemon thread.