/* Code Sample to help Read a file and get started on Baby Names
   Period 6 Jan 5th, 2011
*/
   import java.io.*;    // for File
   import java.util.*;  // for Scanner
   public class ActOnAFile {
      public static void main(String[] args) throws FileNotFoundException {
   		// Alternative way to establish the Scanner to read the file   	
			//File jello = new File("names.txt");
      	//Scanner input = new Scanner(jello);
         Scanner input = new Scanner(new File("names.txt"));
			// Assume the first name has already been read from console      	
         String firstName = "Earl";
      
	     	String line = "";  // Make scope available outside of While Loop
      	boolean found = false;
        
         while (input.hasNextLine() && !found) {
            line = input.nextLine();
            String firstOfLine = line.substring(0, line.indexOf(" "));
            if (firstName.equalsIgnoreCase(firstOfLine)) {
               System.out.println(line);
               found = true;
            }
          } 
    		 // Demonstrate line accessible outside of while loop      
			 System.out.println(line);
         
      }
   }
