import java.io.*;
import java.util.*;
/**********************************************************************
 * This class deals with two methods main and processData.  These methods
 * both deal with printing dates.
 * 
 * @author  Justin Cruz
 * @version V1
 **********************************************************************
 * Name: Justin Cruz
 * Date: 1-22-07
 * Lab #: 4
 * Section: 1
 *********************************************************************/
public class IO_cruzja_Remember
{
    private static Scanner        dateScanner;
    private static PrintWriter    screen;
   /****************************************************************
   * This main method will be used to print the date using the
	* GregorianCalendar and uses the method processDates
   *
   * @param args Command line arguments, get data from txt files
   *****************************************************************/
    public static void main(String[] args)
    {
       GregorianCalendar        today;
       String                   name;
		 File                     dates;
		 int                      arrayLength;     
		 
       today    = new GregorianCalendar();
       screen   = new PrintWriter(System.out);

       screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
       screen.flush();       
			
		 arrayLength = args.length;
			
		 for(int x = 0; x < arrayLength; x++)
		 {
		 	 dates    = new File(args[x]);
			 
			 try
			 {
	          dateScanner = new Scanner(dates);
			 }
			 catch(java.io.FileNotFoundException fnfe)
			 {
			    System.out.println("The file was not found.\n Program End");
				 System.exit(0);
			 }
			 
			 processDates(today);
		 }
    }
    

	/****************************************************************
   * This main method will be used to print the date using the
	* GregorianCalendar and uses the method processDates
   *
   * @param today A GregorianCalendar object that is used to get the month and day
   *****************************************************************/
    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();
          }
       }
    }
    

}
