import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; import java.util.InputMismatchException; public class Main { public static void processFile(String fname) throws FileNotFoundException, InputMismatchException { Scanner inFile = new Scanner(new File(fname)); int x = inFile.nextInt(); System.out.println("Data is: "+x); inFile.close(); } public static void main(String[] args) { try { Scanner in = new Scanner(System.in); System.out.print("Input the file pathname: "); String fname = in.next(); processFile(fname); in.close(); } catch (FileNotFoundException e) { System.out.println("Cannot open the file. Please check or ask CS2312 helpers."); } catch (InputMismatchException e) { System.out.println("Cannot read the required number from the opened file. Please download from Helena's website again."); } } } /* Rundown [in case the file exists and data is read successfully] Input the file pathname: i:\data001.txt Data is: 678 */ /* Rundown [in case the file doesn't exist] Input the file pathname: i:\data01.txt Cannot open the file. Please check or ask CS2312 helpers. */ /* Rundown [in case the beginning of the file is not a number] Input the file pathname: i:\data002.txt Cannot read the required number from the opened file. Please download from Helena's website again. */