Skip to content

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:

IOException


watchDirectory

public void watchDirectory(Path path, Runnable onEvent)

Watch a specific directory and run onEvent when any event occurs.

Throws:

IOException


watchDirectory

public void watchDirectory(Path path, FileChangeHandler handler)

Watch a specific directory and receive granular event details via a callback.

Throws:

IOException


watchDirectory

public void watchDirectory(Path path, FileChangeHandler handler, String[] extensions)

Throws:

IOException


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:

IOException


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.