@TOC## 配置文件中读取文件存储路径
配置文件中读取文件存储路径
private String getReportAddress() {
String classesPath;
try {
classesPath = this.getClass().getClassLoader().getResource("").toURI().getPath();
} catch (URISyntaxException e) {
classesPath = this.getClass().getClassLoader().getResource("").getPath().replaceAll("%20"," ");
}
String tempdir= "";
//tomcat下
if (classesPath.indexOf("wtpwebapps")!=-1) {
tempdir = classesPath.split("wtpwebapps")[0];
//weblogic下
}else if (classesPath.indexOf("domains")!=-1) {
tempdir = classesPath.split("domains")[0];
//其他
}else {
tempdir = classesPath.split("webapps")[0];
}
if(!"/".equals(tempdir.substring(tempdir.length()-1))){
tempdir += File.separator;
}
String dir = tempdir+"reportFile";
//String dir = System.getProperty("user.dir").replace("bin", "reportFile");
//没有文件夹则创建文件夹在tomcat目录下建立reportFile文件夹
File fileLocation = new File(dir);
if(!fileLocation.exists()){
fileLocation.mkdir();
}
return dir+File.separator;
}