   import java.io.*;
   import java.util.*;
   
/*****************************************************
* Outputs todays date and the data that corresponds to
* that date
*
* @author - Ben Rodes
* @version V1 - 1/22/07
*
******************************************************/
//Ben Rodes
//2:30 Lab
//date 1/22/07
//Lab 4
    public class IO_rodesbd_Remember
   {
      private static Scanner        dateScanner;
      private static PrintWriter    screen;
   
   /****************************
   * Out puts the date and what
   * information applies to that
   * date
   * 
   * @param args Command line arguements
   * @exception FileNotFoundException
   *******************************/
   
       public static void main(String[] args)
      {
         File dates;
         GregorianCalendar        today;
         String                   name;       
         today    = new GregorianCalendar();
         screen   = new PrintWriter(System.out);
       
         if(args.length > 0)
         {
         
         //Scans each file name entered in the command line
         
            for(int count = 0; count < args.length; count++)
            {
               dates	= new File (args[count]);
            
            //determines if args[0] is a valid file,
            //if so it is used as a file name
            
               try
               {
                  dateScanner = new Scanner(dates);
               }  
                   catch(FileNotFoundException fnfe)
                  {
                     System.out.println("File not found");
                  }
               
               screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
               screen.flush();       
            
               processDates(today);
            
            }
         }
         
         //instantiates dateScanner to user input,
         // if no arguments are being passed in.
         
         else
         {
            dateScanner = new Scanner(System.in);
         
         
            screen.printf(Locale.US, "\nToday's Date: %1$te %1$tB %1$tY\n", today);
            screen.flush();       
         
            processDates(today);
         }
      }
    
   	/**********************************************
   	* Processes dates
   	*
   	* @param today The current date
   	**********************************************/
       private static void processDates(GregorianCalendar today)
      {
         int           day, month;              
         String        name;
       
      
       // Use the '\t' (tab) and '/' characters as delimiters
         dateScanner.useDelimiter("[\t/]");
          
      
         //processes the date
      	 
         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();
            }
         }
      }
    
   
   }
