   import java.io.*;
   import java.util.*;
/***********************************************
 *	Reads Inputted Files and Outputs the Important
 * Events for Today's Date.
 *
 * @author - Michael Siltz (Modified Code by E. Adams)
 * @version 2
 ************************************************/
// Date: January 22, 2007
// Section 1
// Lab 4
    public class IO_siltzma_Remember
   {
      private static Scanner        dateScanner;
      private static PrintWriter    screen;
    
   
   /********************************************
    * Reads in the file names and finds the important events
	 * pertaining to today's date. It then outputs today's date
	 * and then each important event on the lines that follow.
    *
    * @param args The files to be read in
    *********************************************/ 
       public static void main(String[] args)
      {
         GregorianCalendar        today;
         String                   name;       
         File[] 						 dates; // Creates an array of File objects
       
         today    = new GregorianCalendar();
         screen   = new PrintWriter(System.out);
         dates 	= new File[args.length]; // Instantiates dates
      	
         screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
         screen.flush(); // Flushes the buffer      
      	
         try
         {        		 	
         	// Loops the process for each file inputted as a command line argument
            for (int index = 0; index < args.length; index++)
            {
               dates[index] = new File(args[index]);
               dateScanner = new Scanner(dates[index]);
               processDates(today);
            } 				
         }
         
         // Catches the FileNotFoundException
             catch (FileNotFoundException fnfe)
            {
               screen.println("File not found.");
               screen.flush();
            }   			 
      }
    
   
   
       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())
         {        
         	// Gets the values from the file
            month = dateScanner.nextInt(); // Gets the month
            day   = dateScanner.nextInt(); // Gets the day
            name  = dateScanner.nextLine(); // Gets the string representing something important for that month/day
         
            if ((month == (today.get(Calendar.MONTH)+1)) && 
              (day   == today.get(Calendar.DAY_OF_MONTH)))
            {
            	// Prints each important event for that month/day          
               screen.printf("%s\n", name);
               screen.flush();
            }
         }
      }
    
   
   }
