   import java.io.*;
   import java.util.*;
/********************************************************************** 
 *   This class is designed to works with IO
 *
 *   author:  Dat Nguyen
 *   date:		1/22/2007
 *   lab4 
 *   section 2
 *
 **********************************************************************/

    public class IO_nguyendq_Remember
   {
      private static Scanner        dateScanner;
      private static PrintWriter    screen;
    
   
   /********************************************************** 
    * This main method printout today date and match the 
    * birthday of names in the birthday.txt file and output 
    * the date and the name that match the date.
    *
    * @param args  array of string
    **********************************************************/
       public static void main(String[] args)
      {
         GregorianCalendar        today;
         String                   name;
         File							  dates;       
      
       
         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();
       
         //for loop allows input of multiple files
         for (int count = 0; count < args.length; count++)
         {
            dates = new File(args[count]);       
         
            //try catch block to prevent FileNotFoundException
            try
            {
            
               dateScanner = new Scanner(dates);
               processDates(today);
            }
                catch (FileNotFoundException fnfe)
               {
                  screen.printf("File is 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())
         {
            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();
            }
         }
      }
    
   
   }
