try {
String url = LotteryID + "/" + ChannelID + "/" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()
.getTime()) + "/";
File file = new File("src/main/resources/" + url);
//如果目录不存在,则创建目录;
if (!file.exists()) {
//mkdirs是创建多级目录,而mkdir是创建单级目录;
file.mkdirs();
}
File fileTxt = new File("src/main/resources/" + url + WareIssue + ".txt");
System.out.println("filePath:" + fileTxt.getAbsolutePath());
FileWriter writer = new FileWriter(fileTxt);
writer.write(fileContent.toString());
writer.flush();
writer.close();
} catch (IOException e) {
System.out.println("IO txt file Exception:" + e);
}
Java写txt文件到多级目录
最新推荐文章于 2020-11-12 10:04:47 发布