import java.io.*;

/**
 * A utility application that repeatedly saves a snapshot of the files in the
 * current directory.
 *
 * This version uses a RepeatingDirectoryLister

 * @author  Prof. David Bernstein, James Madison University
 * @version 1
 */
public class AutoDir
{
    /**
     * The entry point of the application.
     *
     * args[0] contains the delay between snapshots.
     *
     * @param args The command-line arguments.
     */
    public static void main(String[] args) throws IOException
    {
        long        delay;

        // Process the command-line arguments
        delay = 1000;
        if ((args != null) && (args.length > 0))
        {
            delay = Long.parseLong(args[0]);
        }
        

        // Construct and start the RepeatingDirectoryLister
        RepeatingDirectoryLister rdl = new RepeatingDirectoryLister(delay);
        rdl.start();

        // The command-line "user interface" (such as it is)
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Press [Enter] to stop.");
        in.readLine();
        rdl.stop();
    }
}
