Package io.github.qishr.cascara.common.io.filewatcher
Class FileWatcher
java.lang.Object
io.github.qishr.cascara.common.io.filewatcher.FileWatcher
public class FileWatcher
Constructor Summary
| Constructor | Description |
|---|---|
| FileWatcher() |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public void | watchFile(Path path, Runnable onEvent) | |
| public void | watchDirectory(Path path, Runnable onEvent) | Watch a specific directory and run onEvent when any event occurs. |
| public void | watchDirectory(Path path, FileChangeHandler handler) | Watch a specific directory and receive granular event details via a callback. |
| public void | watchDirectory(Path path, FileChangeHandler handler, String[] extensions) | |
| public void | watchDirectoryRecursively(Path path, Runnable onEvent) | Watch a specific directory and all subdirectories, and run onEvent when any event occurs. |
| public void | resumeWatching() | Start watching for file changes. |
| public void | pauseWatching() | Stop watching for file changes until resumeWatching() is called. |
| public void | clear() | Stop watching all currently watched files and directories. |
Method Details
watchFile
public void watchFile(Path path, Runnable onEvent)
Throws:
watchDirectory
public void watchDirectory(Path path, Runnable onEvent)
Watch a specific directory and run onEvent when any event occurs.
Throws:
watchDirectory
public void watchDirectory(Path path, FileChangeHandler handler)
Watch a specific directory and receive granular event details via a callback.
Throws:
watchDirectory
public void watchDirectory(Path path, FileChangeHandler handler, String[] extensions)
Throws:
watchDirectoryRecursively
public void watchDirectoryRecursively(Path path, Runnable onEvent)
Watch a specific directory and all subdirectories, and run onEvent when any event occurs.This registers the current tree and dynamically registers new subdirectories.
Throws:
resumeWatching
public void resumeWatching()
Start watching for file changes.
pauseWatching
public void pauseWatching()
Stop watching for file changes until resumeWatching() is called.
clear
public void clear()
Stop watching all currently watched files and directories.