Package com.nt.udc.util
Class FileSystemCleaner
java.lang.Object
com.nt.udc.util.FileSystemCleaner
- All Implemented Interfaces:
ActionListener
,EventListener
This class handles file system cleaning, and has the option
to make it timer based. The main idea is to use this is
a routine where a directory becomes "expired", and is no longer
used. When a directory is no longer in use, add it to the cleaner, and
the timer will eventually delete it. Also, one may explicitly call
"clean()" to delete any directories that the clean currently knows about.
-
Constructor Summary
ConstructorsConstructorDescriptionFileSystemCleaner
(LoggerIfc logger) Constructs a FileSystemCleaner with a logger.FileSystemCleaner
(LoggerIfc logger, int cleanerDelay) Constructs a FileSystemCleaner with a logger and timer delay. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Event handler for timer.void
Adds a directory to delete.void
Adds some directories to delete.void
clean()
Cleans the known directories and files.void
Starts the timer.void
startCleaning
(int delay) Starts cleaning with a given delay.void
Stops the cleaning timer.toString()
Converts directory info to a String.
-
Constructor Details
-
FileSystemCleaner
Constructs a FileSystemCleaner with a logger.- Parameters:
logger
- Logger for errors and warnings.
-
FileSystemCleaner
Constructs a FileSystemCleaner with a logger and timer delay.- Parameters:
logger
- Logger for errors and warnings.cleanerDelay
- Delay for timer.
-
-
Method Details
-
addDir
Adds a directory to delete.- Parameters:
dir
- Directory to delete.
-
addDirs
Adds some directories to delete.- Parameters:
dirs
- Directories to delete.
-
clean
Cleans the known directories and files.- Throws:
IOException
-
startCleaning
public void startCleaning()Starts the timer. -
startCleaning
public void startCleaning(int delay) Starts cleaning with a given delay.- Parameters:
delay
- Timer delay.
-
stopCleaning
public void stopCleaning()Stops the cleaning timer. -
actionPerformed
Event handler for timer.- Specified by:
actionPerformed
in interfaceActionListener
-
toString
Converts directory info to a String.
-