|
What happens with a bad file name? A good answer might be:An IOException is thrown. |
IOExceptionsMost IO methods throw an IOException when an error is encountered. A method that uses one of these IO methods must either (1) say throws IOException in its header, or (2) perform its IO in a try{} block and catch exceptions. Here is the example program modified to catch exceptions:
The constructor, the write() method, and the close() method can throw an IOException. All are caught by the catch block. This program opens the file "reaper.txt" for appending. Run it and see what it does. |
QUESTION 9:If you are running Microsoft NT change the permissions of the file "reaper.txt" to read only (right-click on the file name in Explorer and go to properties). Now run the program again. What happens? Click Here after you have answered the question |