| java.lang.Object com.anthonyeden.lib.util.FileMonitor
FileMonitor | public class FileMonitor implements Runnable(Code) | | Class which monitors a file in a thread separate from the main application.
If the file changes then the reload() method of the given target will be
executed.
author: Anthony Eden |
Field Summary | |
final public static int | DEFAULT_DELAY The default delay value (5 seconds) for checking for modifications. |
Method Summary | |
public long | getDelay() Get the delay between file checks. | public File | getFile() Get the file which is being monitored. | public void | run() The thread's run method. | public void | setDelay(long delay) Set the delay between checks. | public void | startMonitor() Start the monitoring thread. | public void | stopMonitor() Stop the monitoring thread. |
DEFAULT_DELAY | final public static int DEFAULT_DELAY(Code) | | The default delay value (5 seconds) for checking for modifications.
|
FileMonitor | public FileMonitor(File file, Reloadable target)(Code) | | Construct a new FileMonitor for the given file and target. The default
delay time will be used.
Parameters: file - The file to monitor Parameters: target - The target |
FileMonitor | public FileMonitor(File file, long delay, Reloadable target)(Code) | | Construct a new FileMonitor for the given file and target. The given
delay time will be used.
Parameters: file - The file to monitor Parameters: delay - The delay time Parameters: target - The target |
getDelay | public long getDelay()(Code) | | Get the delay between file checks.
The delay in milliseconds |
getFile | public File getFile()(Code) | | Get the file which is being monitored.
The monitored file |
run | public void run()(Code) | | The thread's run method. This method should not be executed directly
nor should a thread be manually created, rather the startMonitor()
and stopMonitor() methods should be used to start and stop
the monitor.
|
setDelay | public void setDelay(long delay)(Code) | | Set the delay between checks. If the thread is already sleeping then
this delay will take effect during the next sleep.
Parameters: delay - The delay in milliseconds |
startMonitor | public void startMonitor()(Code) | | Start the monitoring thread. If the thread is already running then
this method will not attempt to start a new thread.
|
stopMonitor | public void stopMonitor()(Code) | | Stop the monitoring thread. If the monitoring thread is not running
then this method will do nothing.
|
|
|