Java保存文本文件

时间:2021-06-13 03:32:46
String requestData = "something you want to save";
String saveFilePath = "C:\\Users\\xxxx\\Documents\\xxxxx\\";
String dateNow = (new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss")).format(new Date());
java.io.FileWriter fw = new java.io.FileWriter(saveFilePath + dateNow +".txt");
fw.write(requestData);
fw.close();