Package namespace; import Java. io. *; public class iotest {public static void main (string Arg []) {filewriter writer = NULL; // The reference is defined outside try, in this way, you can call try {writer = new filewriter ("F: \ java.txt") in the non-existing code block; // try writer on the code that causes the exception. write ("ABC");} catch (ioexception ex) {system. out. println (ex. tostring ();} finally // do not forget to release the resource {try // close will also cause exceptions, as well as try {If (writer! = NULL) // determine whether some resources exist during the course of disabling resources. If the resources do not exist, an exception will occur, because the first new sentence may be abnormal, in this case, the finally file contains the error writer. close ();} catch (ioexception ex) {system. out. println (ex. tostring () ;}}}/** standard write Method for Io Exception Handling * 1. define the reference outside, so that you can use it all. You can use it in a try catch code block that does not exist finally * 2. when resources are released, exceptions are also thrown, and * 3 needs to be captured. release the resource and use finally to release the resource. Determine whether the resource exists before the resource is released to check whether the resource exists. If the resource does not exist, an exception will also be thrown * 14:59:50 ****/