public class DirectoryWatcher extends java.lang.Thread
Utility class to watch directories for changes.
Modifiers | Name | Description |
---|---|---|
static interface |
DirectoryWatcher.FileChangeListener |
Interface for FileChangeListeners |
Modifiers | Name | Description |
---|---|---|
static java.lang.String |
SVN_DIR_NAME |
Fields inherited from class | Fields |
---|---|
class java.lang.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(java.io.File dir, java.util.List<java.lang.String> fileExtensions) Adds a directory to watch for the given file and extensions. |
|
public void |
addWatchDirectory(java.io.File dir) Adds a directory to watch for the given file. |
|
public void |
addWatchDirectory(java.io.File dir, java.lang.String extension) Adds a directory to watch for the given file and extensions. |
|
public void |
addWatchFile(java.io.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 java.lang.Thread |
java.lang.Thread#run(), java.lang.Thread#toString(), java.lang.Thread#isInterrupted(), java.lang.Thread#currentThread(), java.lang.Thread#onSpinWait(), java.lang.Thread#getName(), java.lang.Thread#join(), java.lang.Thread#join(long, int), java.lang.Thread#join(long), java.lang.Thread#getThreadGroup(), java.lang.Thread#setContextClassLoader(java.lang.ClassLoader), java.lang.Thread#getStackTrace(), java.lang.Thread#holdsLock(java.lang.Object), java.lang.Thread#checkAccess(), java.lang.Thread#dumpStack(), java.lang.Thread#setPriority(int), java.lang.Thread#setDaemon(boolean), java.lang.Thread#start(), java.lang.Thread#yield(), java.lang.Thread#sleep(long, int), java.lang.Thread#sleep(long), java.lang.Thread#stop(), java.lang.Thread#interrupt(), java.lang.Thread#interrupted(), java.lang.Thread#isAlive(), java.lang.Thread#suspend(), java.lang.Thread#resume(), java.lang.Thread#getPriority(), java.lang.Thread#setName(java.lang.String), java.lang.Thread#activeCount(), java.lang.Thread#enumerate([Ljava.lang.Thread;), java.lang.Thread#countStackFrames(), java.lang.Thread#isDaemon(), java.lang.Thread#getContextClassLoader(), java.lang.Thread#getAllStackTraces(), java.lang.Thread#getId(), java.lang.Thread#getState(), java.lang.Thread#setDefaultUncaughtExceptionHandler(java.lang.Thread$UncaughtExceptionHandler), java.lang.Thread#getDefaultUncaughtExceptionHandler(), java.lang.Thread#getUncaughtExceptionHandler(), java.lang.Thread#setUncaughtExceptionHandler(java.lang.Thread$UncaughtExceptionHandler), java.lang.Thread#wait(long), java.lang.Thread#wait(long, int), java.lang.Thread#wait(), java.lang.Thread#equals(java.lang.Object), java.lang.Thread#hashCode(), java.lang.Thread#getClass(), java.lang.Thread#notify(), java.lang.Thread#notifyAll() |
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