java写文件

写:

/**
* 写文件
* @param path
* @return
* @throws IOException
*/
public BufferedWriter writeFile(final String path) throws IOException {
BufferedWriter writer = new BufferedWriter(new FileWriter(path));

return writer;
}

 

写完别忘了关闭:

writer.close();

 

eg.

writer.writer("hello, world");
writer.newLine();    // 新的一行
wirter.close;            // 写完记得关闭

 

posted @ 2016-04-02 11:05  高手教程  阅读(193)  评论(0编辑  收藏  举报