abstract class AbstractDirectoryWatcher extends java.lang.Object implements java.lang.Runnable
Backend for DirectoryWatcher
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
addListener(FileChangeListener listener) Adds a file listener that can react to change events |
|
public abstract 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 abstract void |
addWatchFile(java.io.File fileToWatch) Adds a file to the watch list |
|
protected void |
fireOnChange(java.io.File file) |
|
protected void |
fireOnNew(java.io.File file) |
|
public static java.lang.String |
getFilenameExtension(java.lang.String path) Extract the filename extension from the given path, e.g. |
|
protected boolean |
isValidDirectoryToMonitor(java.io.File file) |
|
protected boolean |
isValidFileToMonitor(java.io.File file, java.util.Collection<java.lang.String> fileExtensions) |
|
public void |
removeListener(FileChangeListener listener) Removes a file listener from the current list |
|
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.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Adds a file listener that can react to change events
listener
- The file listenerAdds a directory to watch for the given file and extensions. No String in the fileExtensions list can start with a dot (DirectoryWatcher guarantees that)
dir
- The directoryfileExtensions
- The extensionsAdds a file to the watch list
fileToWatch
- The file to watchExtract the filename extension from the given path, e.g. "mypath/myfile.txt" -> "txt".
path
- the file path (may be null
)null
if noneRemoves 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