Class FileSystemCleaner

java.lang.Object
com.nt.udc.util.FileSystemCleaner
All Implemented Interfaces:
ActionListener, EventListener

public class FileSystemCleaner extends Object implements ActionListener
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 Details

    • FileSystemCleaner

      public FileSystemCleaner(LoggerIfc logger)
      Constructs a FileSystemCleaner with a logger.
      Parameters:
      logger - Logger for errors and warnings.
    • FileSystemCleaner

      public FileSystemCleaner(LoggerIfc logger, int cleanerDelay)
      Constructs a FileSystemCleaner with a logger and timer delay.
      Parameters:
      logger - Logger for errors and warnings.
      cleanerDelay - Delay for timer.
  • Method Details

    • addDir

      public void addDir(File dir)
      Adds a directory to delete.
      Parameters:
      dir - Directory to delete.
    • addDirs

      public void addDirs(File[] dirs)
      Adds some directories to delete.
      Parameters:
      dirs - Directories to delete.
    • clean

      public void clean() throws IOException
      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

      public void actionPerformed(ActionEvent ae)
      Event handler for timer.
      Specified by:
      actionPerformed in interface ActionListener
    • toString

      public String toString()
      Converts directory info to a String.
      Overrides:
      toString in class Object
      Returns:
      String representation of FileSystemCleaner