/**
* Example to illustrate reading numbers from a file where the user chooses the
* filename - this version doesn't work becuase it needs to have a try catch
* block to catch a FileNotFoundException or it needs to throw throw that exception
* @author Elizabeth Adams
* @version 1
*/
import java.util.Scanner;
import java.io.*;

public class ReadFromFile_1
{
   public static void main (String[] args) 
	 {
      Scanner fileScan, scan;
      String  filename;
		int number;
		int count;
		
		// initialize count
		count = 0;
		
		// set Scanner to read from keyboard
		scan = new Scanner (System.in);
		
		// prompt to get filename from user
		System.out.println 
		     (" Please enter the name of the file you want to read from");
		System.out.print (" with complete path ");
		
		// get filename
		filename = scan.nextLine();

      // set Scanner to read from desired file 		
		fileScan = new Scanner (new File (filename));

      // Read and process each line of the file
      while (fileScan.hasNext())
      {
         number = fileScan.nextInt();
         System.out.println (" got number " + number);
			count++;
      }
		
		// when out of data print ending message
      System.out.println (" read " + count + " numbers from file - am now done ");
	}	
}
