创建文件并写入内容

java 写入文件

public void createFile() throws IOException{
          ServletContext s1=this.getServletContext();
            String temp=s1.getRealPath("/");
         File f = new File(temp+"log.txt");
        f.createNewFile();
         FileWriter fw=new FileWriter(f,true);
        
         fw.write("ccccccccccccccccccccc001");
         fw.close();
        
    }

 

posted @ 2016-11-06 19:48  甜菜波波  阅读(196)  评论(0编辑  收藏  举报