CS 251 Lab Exercise #10 Due: In Lab, the week of May 2nd, 2011. Main topics: Checked Exceptions Files I/O This week we will be practicing using Checked exceptions and basic file I/O. Getting Started To start this exercise, you should first change into your lab directory and create a directory named 10. You should then change into this new 10 directory and type the following command: cp /home/CS/cs251/pub/lab10/* . Eclipse 1. Open Eclipse 2. Open a new java project named Lab10 3. Import the java files that you just copied into your project. File -¿ Import -¿ General -¿ File System -¿ Browse Files.java A very simple ”driver” class which you can use as a base. Currently the program asks it user for the name of a text file which will be created; have the contents of the array words copied into it; and then be closed. Notice that since the PrintWriter constructor call may throw a FileNotFoundException, which is a checked exception, we must use try - catch blocks appropriately here. Your job is to: 1. add the necessary components to the program so that the the original text file will be re- opened - again for output writing; have the contents of the arraymoreWords appended to it; and then closed again. 2. add the necessary components to the program so that the the text file will be re-opened one last time - this time for input reading; have its contents read (line by line) and printed to the screen; and then closed for the last time. Your finished program will run / produce output similar to: Enter the file name for output: test.txt Enter the file name to append to: test.txt Enter the file name for input: test.txt words[0] = hello words[1] = world words[2] = and words[3] = stuff moreWords[0] = the moreWords[1] = end 1 Compile build and run the class, and fix any errors. Check off 1. Once you finish this lab, you should see your Lab TA to let them know you are finished with this lab so that they can check you off. 2