Package com.norconex.commons.lang.file

# Class FileMonitor

java.lang.Object
com.norconex.commons.lang.file.FileMonitor

public final class FileMonitor extends Object
Class monitoring a `File` for changes and notifying all registered `FileChangeListener`.

Since:
  1.3.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addFileChangeListener(FileChangeListener listener, File file, long period)`
  Adds a monitored file with a FileChangeListener.
  `void`
  `addFileChangeListener(FileChangeListener listener, String fileName, long period)`
  Adds a monitored file with a `FileChangeListener`.
  `protected void`
  `fireFileChangeEvent(FileChangeListener listener, File file)`
  Fires notification that a file changed.
  `static FileMonitor`
  `getInstance()`
  Gets the file monitor instance.
  `void`
  `removeFileChangeListener(FileChangeListener listener, File file)`
  Remove the listener from the notification list.
  `void`
  `removeFileChangeListener(FileChangeListener listener, String fileName)`
  Remove the listener from the notification list.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getInstance

    public static FileMonitor 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 a `FileChangeListener`.
    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

    public void removeFileChangeListener(FileChangeListener listener, String fileName)
    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

    public void removeFileChangeListener(FileChangeListener listener, File file)
    Remove the listener from the notification list.
    Parameters:
      `listener` - the listener to be removed.
      `file` - the file for which to remove the listener

  - ### fireFileChangeEvent

    protected void fireFileChangeEvent(FileChangeListener listener, File file)
    Fires notification that a file changed.
    Parameters:
      `listener` - file change listener
      `file` - the file that changed