import java.util.*;
import java.io.*;

/* COP3330
 *
 * Example of try catch or throws
 */

public class Example {

	public static String strFl = "example1.txt";

	public static void main(String [] args) throws FileNotFoundException  {
	
		boolean found = false;
		
	   	Scanner fIn = null;
	
		while (!(found)) {
			try {
				fIn = Example.getScanner(Example.strFl);
				found = true;
			}
			catch (FileNotFoundException e) {
				e.printStackTrace();
				try {
					
				}
				catch(Exception e){
					System.err.println("\n-------\n File: " + Example.strFl + " could not be found");
					Example.strFl = getFileFromUser();
				}
			}
		}
		
		System.out.println(fIn.nextInt());
		//System.out.println(fIn.nextInt());
	}
	
	public static String getFileFromUser(){
		Scanner stdin = new Scanner(System.in);
		System.out.println("Enter the file name: ");
		String s = stdin.nextInt();
		return s;
	}
	
	public static Scanner getScanner(String fileName) throws FileNotFoundException{
		return new Scanner(new File(fileName));
	}
}
