- 获取本机resources下的路径
String fileurl = WkReportItemServiceImpl.getFileUrl();
File directory = new File(fileurl);
String reportPath = directory.getCanonicalPath();
String resource = reportPath + "/excel/months.xls";
public static String getFileUrl () throws IOException {
String os = System.getProperty("os.name");
File directory;
if (os != null && os.toLowerCase().startsWith("windows")) {
directory = new File("snowy-modules/snowy-main-app/src/main/resources");
System.out.println(String.format("当前系统版本是:%s", os));
} else if (os != null && os.toLowerCase().startsWith("linux")) {
directory = new File("/root");
System.out.println(String.format("当前系统版本是:%s", os));
} else {
directory = new File("/root");
System.out.println(String.format("当前系统版本是:%s", os));
}
String reportPath = directory.getCanonicalPath();
return reportPath;
}