public static void DateToFile(String templateId,String json,String path) throws IOException{
File fileOne = new File(path);//path根据情况自己定义
File file = new File(path+"文件名"+".txt");
if(!fileOne.mkdirs()){//如果不存在目录,创建目录
logger.info("文件目录生成失败");
}
if (!file.exists()) {//如果没做文件创建文件
file.createNewFile();
}
try(FileOutputStream templateFile = new FileOutputStream(file)){
byte[] contentInBytes = json.getBytes();
templateFile.write(contentInBytes);
templateFile.flush();
templateFile.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
File fileOne = new File(path);//path根据情况自己定义
File file = new File(path+"文件名"+".txt");
if(!fileOne.mkdirs()){//如果不存在目录,创建目录
logger.info("文件目录生成失败");
}
if (!file.exists()) {//如果没做文件创建文件
file.createNewFile();
}
try(FileOutputStream templateFile = new FileOutputStream(file)){
byte[] contentInBytes = json.getBytes();
templateFile.write(contentInBytes);
templateFile.flush();
templateFile.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}