双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

自动生成文件到WEB-INF下,路径怎么写?怎么配置根路径?

blue小脚丫 blue小脚丫 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我写了一个方法,用来在有异常的时候自动生成日志文件并将异常信息记录在此文件中,现打算把这个日志文件放项目的WEB-INF下,路径要怎么写?
领导说要配置根路径,根路径是什么?怎么配置?求大神指教。

public void createRepairLog(String p_registNo, String p_verifylossNo) {
String details = "事故号:" + p_registNo + "定损单号:" + p_verifylossNo;
BufferedWriter out = null;
OutputStreamWriter osw = null;
FileOutputStream fos = null;
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String exDate = sdf.format(d);
/* 文件名 */
File file = new File("test.txt"); //路径要怎么写?
try {
file.createNewFile();
fos = new FileOutputStream(file, true);
if(fos==null){
}else{

}
osw = new OutputStreamWriter(fos);
out = new BufferedWriter(osw);
out.write(exDate + System.getProperty("line.separator"));
// 将String写入到文件中
out.write(details);
out.flush();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
try {
fos.close();
osw.close();
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
...全文
评论 4
收藏 已收藏
分享
返回顶部
blue小脚丫
Web 开发 81,108 成员 341,721 内容