Class FileMonitor


  • public final class FileMonitor
    extends Object
    Class monitoring a File for changes and notifying all registered IFileChangeListener.
    Since:
    1.3.0
    Author:
    Pascal Essiembre
    • Method Detail

      • getInstance

        public static FileMonitor getInstance()
        Gets the file monitor instance.
        Returns:
        file monitor instance
      • addFileChangeListener

        public void addFileChangeListener​(IFileChangeListener 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​(IFileChangeListener 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​(IFileChangeListener 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​(IFileChangeListener listener,
                                           File file)
        Fires notification that a file changed.
        Parameters:
        listener - file change listener
        file - the file that changed