The complete try/catch/finally statement
File file; /* defines file to be object of class File */
- try{
- file = new File("filenameyouwant");
- . . . . .
- file.write("stuff put out");
- } catch (IOException e) {
- /* This catches ALL I/O errors including
- read and write stuff */
- /* Handle Exception somehow */
- return;
- }
- /* but the optional finally clause will be executed
- whether or not code terminates normally */
- finally {
- file.close();
- }