Package org.apache.commons.io.monitor
Class FileAlterationMonitor
java.lang.Object
org.apache.commons.io.monitor.FileAlterationMonitor
- All Implemented Interfaces:
- Runnable
A runnable that spawns a monitoring thread triggering any
 registered 
FileAlterationObserver at a specified interval.- Since:
- 2.0
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a monitor with a default interval of 10 seconds.FileAlterationMonitor(long intervalMillis) Constructs a monitor with the specified interval.FileAlterationMonitor(long interval, Collection<FileAlterationObserver> observers) Constructs a monitor with the specified interval and collection of observers.FileAlterationMonitor(long interval, FileAlterationObserver... observers) Constructs a monitor with the specified interval and set of observers.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddObserver(FileAlterationObserver observer) Adds a file system observer to this monitor.longReturns the interval.Returns the set ofFileAlterationObserverregistered with this monitor.voidremoveObserver(FileAlterationObserver observer) Removes a file system observer from this monitor.voidrun()Runs this monitor.voidsetThreadFactory(ThreadFactory threadFactory) Sets the thread factory.voidstart()Starts monitoring.voidstop()Stops monitoring.voidstop(long stopInterval) Stops monitoring.
- 
Constructor Details- 
FileAlterationMonitorpublic FileAlterationMonitor()Constructs a monitor with a default interval of 10 seconds.
- 
FileAlterationMonitorConstructs a monitor with the specified interval.- Parameters:
- intervalMillis- The amount of time in milliseconds to wait between checks of the file system.
 
- 
FileAlterationMonitorConstructs a monitor with the specified interval and collection of observers.- Parameters:
- interval- The amount of time in milliseconds to wait between checks of the file system.
- observers- The collection of observers to add to the monitor.
- Since:
- 2.9.0
 
- 
FileAlterationMonitorConstructs a monitor with the specified interval and set of observers.- Parameters:
- interval- The amount of time in milliseconds to wait between checks of the file system.
- observers- The set of observers to add to the monitor.
 
 
- 
- 
Method Details- 
addObserverAdds a file system observer to this monitor.- Parameters:
- observer- The file system observer to add
 
- 
getIntervalReturns the interval.- Returns:
- the interval
 
- 
getObserversReturns the set ofFileAlterationObserverregistered with this monitor.- Returns:
- The set of FileAlterationObserver
 
- 
removeObserverRemoves a file system observer from this monitor.- Parameters:
- observer- The file system observer to remove
 
- 
runRuns this monitor.
- 
setThreadFactorySets the thread factory.- Parameters:
- threadFactory- the thread factory
 
- 
startStarts monitoring.- Throws:
- Exception- if an error occurs initializing the observer
 
- 
stopStops monitoring.- Throws:
- Exception- if an error occurs initializing the observer
 
- 
stopStops monitoring.- Parameters:
- stopInterval- the amount of time in milliseconds to wait for the thread to finish. A value of zero will wait until the thread is finished (see- Thread.join(long)).
- Throws:
- Exception- if an error occurs initializing the observer
- Since:
- 2.1
 
 
-