/**
*  This program has the wrong catch block so in order
*  to get it to compile, it requires a throws IOException
*  THINGS TO EXPERIMENT WITH
*  run it and enter a non-existent filename and see what  happens
*  take the throws out and try to re-compile it and see what happens

*  @author ???? - modified by Elizabeth Adams
*  @version ??? - September 5, 2008
*/
 
     
import java.util.Scanner;  
import java.io.*;
public class ReadFromFile5  
{
  
public static void main (String [] args)throws IOException
   {
      String fileName;
      Scanner fileScanner;
      Scanner keyboard;
     
int value;
     
      keyboard =
new Scanner (System.in);
      System.out.println
           (
" Please enter name of file holding integers and hit return ");
      fileName = keyboard.nextLine();
     
      System.out.println 
// echo of user's filename
           (" The name of the file you want to open is " + fileName);
        
     
try
            {
        
// a second Scanner object is needed. First one read from keyboard
         fileScanner = new Scanner (new File (fileName));
  
           
// if file is found, read integers from it while there are
                  // integers to read     
         while (fileScanner.hasNextInt())
         {
           value = fileScanner.nextInt();
           System.out.println  
// echoes value picked up
                       (" The value you got from the file is " + value);
         }
// end while
      } // end try 
        
             
// silly catch because there's no array in program
      catch (ArrayIndexOutOfBoundsException  aioobe)
      {
         System.out.println 
// feed back to user
         (" The file you wanted to open was not found ");
      }
// end catch
   } // end main
} // end class