package itcast.java16; import java.io.FileWriter; import java.io.IOException; /* * IO异常处理方式 * */ public class FileWriterDemo2 { public static void main(String[] args) { FileWriter fw =null; try { fw = new FileWriter("demo.txt"); fw.write("abcde"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (fw != null) fw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }