标签:trace 目录 字符 缓冲区 int pre oid ring creat
public static void createFileAndWriter(String message) {
File file = new File("F:\\CreateDemo\\");
if (!file.exists()) {
file.mkdir();//创建一个新目录
}
FileWriter fileWriter=null;
BufferedWriter writer = null;
try {
//当该目录下不存在demo.txt文件时,会自动创建
fileWriter=new FileWriter("F:\\CreateDemo\\demo.txt");
//创建一个缓冲区,加快写入速度
writer = new BufferedWriter(fileWriter);
writer.write(message);
writer.close();
fileWriter.close();
} catch (IOException e) {
System.out.println("写入信息发生错误!");
e.printStackTrace();
}
}
标签:trace 目录 字符 缓冲区 int pre oid ring creat
原文地址:https://www.cnblogs.com/czgxxwz/p/10286680.html