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) | Simple delegate, as true file-specific watching is complicated. |
| 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. |
| public static void | clearAll() | Clears all file watchers globally |
Method Details
watchFile
public void watchFile(Path path, Runnable onEvent)
Simple delegate, as true file-specific watching is complicated.
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.
clearAll
public static void clearAll()
Clears all file watchers globally