// 仅作为学习笔记
/*
IO 异常处理方式
*/
import java.io.*;
class FileWriterDemo
{
public static void main(String []args)
{
FileWriter fw = null;//先建立引用
try
{
fw = new FileWriter("Demo.txt");//初始化
fw.write("Test");
}
catch (IOException e)
{
System.out.println(e.toString());
}
finally
{
try
{
if(fw != null)
fw.close();//刷新流 并关闭流
}
catch (IOException e)
{
System.out.println(e.toString());
}
}
}
}