// 先从当前类所处路径的根目录中寻找属性文件 java.io.InputStream in = loader.getResourceAsStream(propFile); if (in != null) return in;
// 没有找到,就从该类所处的包目录中查找属性文件 Package pack = cls.getPackage(); if (pack != null) { String packName = pack.getName(); String path = ""; if (packName.indexOf(".") < 0) path = packName + "/"; else { int start = 0, end = 0; end = packName.indexOf("."); while (end != -1) { path = path + packName.substring(start, end) + "/"; start = end + 1; end = packName.indexOf(".", start); } path = path + packName.substring(start) + "/"; } in = loader.getResourceAsStream(path + propFile); if (in != null) return in; }
// 如果没有找到,再从当前系统的用户目录中进行查找 java.io.File f = null; String curDir = System.getProperty("user.dir"); f = new java.io.File(curDir, propFile); if (f.exists()) return new java.io.FileInputStream(f);
for (int i = 0; i < cps.length; i++) { f = new java.io.File(cps[i], propFile); if (f.exists()) break; f = null; } if (f != null) return new java.io.FileInputStream(f); return null; } catch (Exception e) { throw new RuntimeException(e); }
// 先从当前类所处路径的根目录中寻找属性文件 java.io.InputStream in = loader.getResourceAsStream(propFile); if (in != null) return propFile;
// 没有找到,就从该类所处的包目录中查找属性文件 Package pack = cls.getPackage(); if (pack != null) { String packName = pack.getName(); String path = ""; if (packName.indexOf(".") < 0) path = packName + "/"; else { int start = 0, end = 0; end = packName.indexOf("."); while (end != -1) { path = path + packName.substring(start, end) + "/"; start = end + 1; end = packName.indexOf(".", start); } path = path + packName.substring(start) + "/"; } in = loader.getResourceAsStream(path + propFile); if (in != null) return path; }
// 如果没有找到,再从当前系统的用户目录中进行查找 java.io.File f = null; String curDir = System.getProperty("user.dir"); f = new java.io.File(curDir, propFile); if (f.exists()) return f.getAbsolutePath();
for (int i = 0; i < cps.length; i++) { f = new java.io.File(cps[i], propFile); if (f.exists()) break; f = null; } if (f != null) return f.getAbsolutePath(); return null; } catch (Exception e) { throw new RuntimeException(e); }