import java.io.*;
import java.util.*;
/*******************************************************************
 * This program takes in args and uses dateScanner to print results.
 *
 * @author - Trevor Caudill 
 * @version - V1 - 1/22/07
 * Lab time: MW 1:25-2:15
 * Section 1
 * Lab 4
 *****************************************************************/

public class IO_caudiltt_Remember
{
    private static Scanner        dateScanner;
    private static PrintWriter    screen;
    


    public static void main(String[] args)
    {
       GregorianCalendar        today;
       String                   name;
		 File 						  dates;
		    

       dates 	 = new File (args[0]);
       today    = new GregorianCalendar();
       screen   = new PrintWriter(System.out);
 
		 // loop runs dateScanner for all args of array 
		 for(int count = 0; count < args.length; count++)
		 {
			 dates    = new File(args[count]);
		  
		 try
		 {
		 	dateScanner = new Scanner(dates);
		 }
		 // handles a fileNotFoundException and prints a message.
		 catch(FileNotFoundException fnfe)
		 {
		 	System.out.println("Could not find the file");
		 }
			
		 screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
       screen.flush();

       processDates(today);
		 }// end for loop
		 
		 
     
    }
    


    private static void processDates(GregorianCalendar today)
    {
       int           day, month;              
       String        name;
       

       // Use the '\t' (tab) and '/' characters as delimiters
       dateScanner.useDelimiter("[\t/]");
          
          
       while (dateScanner.hasNext())
       {
          month = dateScanner.nextInt();
          day   = dateScanner.nextInt();
          name  = dateScanner.nextLine();

          if ((month == (today.get(Calendar.MONTH)+1)) && 
              (day   == today.get(Calendar.DAY_OF_MONTH)))
          {
             screen.printf("%s\n", name);
             screen.flush();
          }
       }
    }// end main
    

}// end Remember class
