java根据windows或者linux获取resources目录下的路径
String filePath = null;
String os = System.getProperty("os.name");
if (os != null && os.toLowerCase().startsWith("windows")) {
filePath = System.getProperty("user.dir") + File.separator + "src"+ File.separator+"main"+ File.separator+"resources" + File.separator + fileName;
} else if (os != null && os.toLowerCase().startsWith("linux")) {
filePath = RSATool.class.getClassLoader().getResource("").getPath() + fileName;
}
浙公网安备 33010602011771号