码迷,mamicode.com
首页 > 其他好文 > 详细

IO异常处理方式

时间:2015-05-08 14:47:05      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

/*

 * IO异常处理方式  

*/

import java.io.*;

public class FileWriterDemo2

{

            public static void main(String[] args)

                 {   

                       FileWriter fw=null;  

                       try   

                         {    

                             fw=new FileWriter("demo.txt");    

                             fw.write("abcdefgh");

                        }  

                       catch(IOException e)  

                       {    

                          System.out.println("catch:"+e.toString());  

                        }   

                      finally  

                       {   

                            try   

                                {   

                                 if(fw!=null)     

                                 fw.close();   

                                }   

                               catch(IOException e)   

                              {    

                                  System.out.println(e.toString());   

                               }   

                      }  

             }

}

IO异常处理方式

标签:

原文地址:http://www.cnblogs.com/binglin/p/4487428.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!