   import java.io.*;
   import java.util.*;
/***************************************************************************
* this class takes the date of today and is passed an amount of command line 
* arguments, if a file exists under the name passed in through the command line 
* the program will print what is listed under todays date
*
* Brian Demarkis
* 1/22/07
* I/O Lab
* Section 2
*
*@author Brian DeMarkis
*@version v1
***************************************************************************/

    public class IO_demarkbc_Remember
   {
      private static Scanner        dateScanner;
      private static PrintWriter    screen;
   /***********************************************************************
	* this method takes in a series of cammand line arguments as filenames and
	* used the processdate method to print output that coordinates with today date
	*
	*
	* @param args[] a command line argument or arguments to be interpreted as filenames
	**************************************************************************/
   
   
       public static void main(String[] args)
      {
         GregorianCalendar        today;// gregorian calendar date for today
         String                   name;       
         File							 dates;
         int                      index;// array counter used to control the loop
         index    = 0;// sets the array countter to start reading at the first element    
         today    = new GregorianCalendar();// instaniates the today variable to be a gregorianCalendar object
         screen   = new PrintWriter(System.out);// instantiates the output device
      
         while(index < args.length)// runs until there is no more command line arguments to be processed
         {
            dates    = new File(args[index]); // assigns the dates variable to the current element of the command line array 
         
            screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);//prints todays date
            screen.flush();       
         
            try
            {    
               dateScanner = new Scanner(dates);// looks to see if the command line argument matches a filename 
            }
                catch(FileNotFoundException fnfe)// catches the exception if the filename is invalid
               {
                  System.out.println("File Not Found");// prints the exception 
               }
            processDates(today);// passes today to processDates
            index++;// updates the array control variable 
         }
      }
    
   
/**********************************************************************
* method used to process what date it is and find out what file to read
* and what part of the file to print 
*
* @param today -  the gregorian calendar version of today's date
************************************************************************/   
       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();
            }
         }
      }
    
   
   }
