Java io将文本数据存储到一个文件中

来源:互联网 发布:手机重低音软件 编辑:程序博客网 时间:2024/06/06 03:48
class Demo 


     { 


          public static void main(String[] args) 


          { 


               FileWriter fw = null; 


               try 
{

                   fw = new FileWrier("z:\\demo.txt"); 


                    fw.write("abc“);

                   fw.flush(); 

                fw.write("kkkk"); 

       } 


              catch(IOException e) 


              { 


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


              } 


              finally 


              { 


                   if(fw!=null) 


                         try 


                         { 


                               fw.close(); 


                         } 


                         catch(IOException e) 


                         { 


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


                         } 


               } 


        } 


  }