public class DirectoryWatcher extends Thread
Utility class to watch directories for changes.
| Modifiers | Name | Description |
|---|---|---|
interface |
DirectoryWatcher.FileChangeListener |
Interface for FileChangeListeners |
| Modifiers | Name | Description |
|---|---|---|
static String |
SVN_DIR_NAME |
| Fields inherited from class | Fields |
|---|---|
class Thread |
MIN_PRIORITY, NORM_PRIORITY, MAX_PRIORITY |
| Constructor and description |
|---|
DirectoryWatcher()Constructor. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addListener(DirectoryWatcher.FileChangeListener listener)Adds a file listener that can react to change events |
|
public void |
addWatchDirectory(File dir, List<String> fileExtensions)Adds a directory to watch for the given file and extensions. |
|
public void |
addWatchDirectory(File dir)Adds a directory to watch for the given file. |
|
public void |
addWatchDirectory(File dir, String extension)Adds a directory to watch for the given file and extensions. |
|
public void |
addWatchFile(File fileToWatch)Adds a file to the watch list |
|
public void |
removeListener(DirectoryWatcher.FileChangeListener listener)Removes a file listener from the current list |
|
public void |
run() |
|
public void |
setActive(boolean active)Sets whether to stop the directory watcher |
|
public void |
setSleepTime(long sleepTime)Sets the amount of time to sleep between checks |
| Methods inherited from class | Name |
|---|---|
class Thread |
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, equals, getAllStackTraces, getClass, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, hashCode, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, notify, notifyAll, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, wait, wait, wait, yield |
Constructor. Automatically selects the best means of watching for file system changes.
Adds a file listener that can react to change events
listener - The file listenerAdds a directory to watch for the given file and extensions.
dir - The directoryfileExtensions - The extensionsAdds a directory to watch for the given file. All files and subdirectories in the directory will be watched.
dir - The directoryAdds a directory to watch for the given file and extensions.
dir - The directoryextension - The extensionAdds a file to the watch list
fileToWatch - The file to watchRemoves a file listener from the current list
listener - The file listenerSets whether to stop the directory watcher
active - False if you want to stop watchingSets the amount of time to sleep between checks
sleepTime - The sleep time