java往一个.txt文件写入内容
1、
try {
String newPath = parentFilePath + "\\" + fileName;
File file = new File(newPath);
if (!file.exists()) {
file.createNewFile();
}
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, false)));
out.write(conent);
} catch (Exception e) {
System.out.println("写入LOG失败:" + conent);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
System.out.println("关闭写文件失败");
}
}

浙公网安备 33010602011771号