这是一个简单的往文件里写内容的方法:
public void writeFile(String fileName, String content) throws Exception {
File f = new File(fileName);
if (f.exists()) {
f.delete();
}
f.createNewFile();
FileWriter fileWriter = new FileWriter(f);
PrintWriter writer = new PrintWriter(fileWriter);
writer.write(content);
writer.flush();
writer.close();
}
posted on 2007-08-24 10:43
teasp 阅读(949)
评论(0) 编辑 收藏 所属分类:
Java学习