eu.emi.dsr.util
Class FileWatcher
java.lang.Object
eu.emi.dsr.util.FileWatcher
- All Implemented Interfaces:
- Runnable
public class FileWatcher
- extends Object
- implements Runnable
helper to watch a set of files and invoke a specific action if one of them was modified.
This should be executed periodically, for example using the scheduled executor
service from the ResourcePool
- Author:
- schuller, a.memon
|
Method Summary |
void |
addTarget(File target)
add a file to be watched
Note: files are stored in a Set, so it is no problem if the same file is added
repeatedly |
boolean |
removeTarget(File target)
|
void |
run()
check if one of the target files has been touched and invoke
the action if it has |
void |
schedule(int delay,
TimeUnit timeunit)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileWatcher
public FileWatcher(File target,
Runnable action)
throws FileNotFoundException
- Throws:
FileNotFoundException
schedule
public void schedule(int delay,
TimeUnit timeunit)
addTarget
public void addTarget(File target)
- add a file to be watched
Note: files are stored in a Set, so it is no problem if the same file is added
repeatedly
- Parameters:
target - - the file to watch
removeTarget
public boolean removeTarget(File target)
run
public void run()
- check if one of the target files has been touched and invoke
the action if it has
- Specified by:
run in interface Runnable
Copyright © 2012. All Rights Reserved.