Your Name ANSWER KEY Lab: Experimenting with Input/Output Part 2 2.4 What output was generated? Today's Date: 28 January 2009 Birthday: Elijah Wood Birthday: Alan Alda 2.6 What occurred and why? This error message was generated. -bash: anniversarys.txt: No such file or directory The command shell could not find the file anniversarys.txt and so did not execute the program. 2.8 What code did you need to add? File dates; 2.10 What did you need to add? if (args.length > 0) dates = new File(args[0]); else { dates = null; // make the compiler happy System.out.println("No file provided. Exiting."); System.exit(1); } NOTE: You could have initialized dates to null before the if statement if you preferred. 2.13 What error message did you get? Remember.java:30: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown dateScanner = new Scanner(dates); 2.16 What changes did you need to make? try { dateScanner = new Scanner(dates); } catch (FileNotFoundException fnfe) { System.out.printf("File, %s, not found. Exiting.", dates.getName()); System.exit(2); } 2.18 What output was generated? Today's Date: 28 January 2009 Birthday: Elijah Wood Birthday: Alan Alda Part 3 3.2 What changes did you need to make? Moved the header to the top. Inside if, added a for loop to process all of the files. If a bad file name, then exited the program. See full program for the code. 3.4 What output was generated? Today's Date: 28 January 2009 Birthday: Elijah Wood Birthday: Alan Alda Review the Java tutorial on Exceptions Work on PA 1