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;            // 写完记得关闭
原文地址:https://www.cnblogs.com/yrqiang/p/5347119.html