Package com.norconex.commons.lang.file
Class FileMonitor
java.lang.Object
com.norconex.commons.lang.file.FileMonitor
Class monitoring a
File for changes and notifying all registered
FileChangeListener.- Since:
- 1.3.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddFileChangeListener(FileChangeListener listener, File file, long period) Adds a monitored file with a FileChangeListener.voidaddFileChangeListener(FileChangeListener listener, String fileName, long period) Adds a monitored file with aFileChangeListener.protected voidfireFileChangeEvent(FileChangeListener listener, File file) Fires notification that a file changed.static FileMonitorGets the file monitor instance.voidremoveFileChangeListener(FileChangeListener listener, File file) Remove the listener from the notification list.voidremoveFileChangeListener(FileChangeListener listener, String fileName) Remove the listener from the notification list.
-
Method Details
-
getInstance
Gets the file monitor instance.- Returns:
- file monitor instance
-
addFileChangeListener
public void addFileChangeListener(FileChangeListener listener, String fileName, long period) throws FileNotFoundException Adds a monitored file with aFileChangeListener.- Parameters:
listener- listener to notify when the file changed.fileName- name of the file to monitor.period- polling period in milliseconds.- Throws:
FileNotFoundException- error with the file
-
addFileChangeListener
public void addFileChangeListener(FileChangeListener listener, File file, long period) throws FileNotFoundException Adds a monitored file with a FileChangeListener.- Parameters:
listener- listener to notify when the file changed.file- the file to monitor.period- polling period in milliseconds.- Throws:
FileNotFoundException- error with the file
-
removeFileChangeListener
Remove the listener from the notification list.- Parameters:
listener- the listener to be removed.fileName- name of the file for which to remove the listener
-
removeFileChangeListener
Remove the listener from the notification list.- Parameters:
listener- the listener to be removed.file- the file for which to remove the listener
-
fireFileChangeEvent
Fires notification that a file changed.- Parameters:
listener- file change listenerfile- the file that changed
-