import java.io.*;
public class IoDemo {
/**
* 关于io的异常处理
* @throws IOException
*/
public static void main(String[] args) {
FileWriter fw=null;//必须定义成全局变量
try {
fw = new FileWriter("demo.text");
fw.write("avcdeeww");
} catch (IOException e) {
e.printStackTrace();
}finally{
if(fw!=null){
try {
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
|
|