關於jive的幾個小問題,請高手指點,多謝先。

wilson751發表於2005-10-19

jive的JiveGlobals.java檔案中,包含方法getJiveProperty()類InitPropLoader的方法getJiveHome(),在這2個方法中我有幾個疑問,寫在相應的語句前,請各位大俠拔刀相助,不勝感激。

class InitPropLoader {
public String getJiveHome() {
String jiveHome = null;
// 1. 類Properties有什麼用途呢?
Properties initProps = new Properties();
InputStream in = null;
try {
// 2. getClass()是誰的方法?
in = getClass().getResourceAsStream("/jive_init.properties");
initProps.load(in);
}catch (Exception e) {
System.err.println("Error reading Jive properties "
+ "in JiveGlobals");
e.printStackTrace();
} finally {
try {
if (in != null) { in.close(); }
} catch (Exception e) {}
}
if (initProps != null) {
jiveHome = initProps.getProperty("jiveHome");
if (jiveHome != null) {
jiveHome = jiveHome.trim();
// 3. jiveHome的值是什麼呢?是整個路徑嗎
while (jiveHome.endsWith("/") || jiveHome.endsWith("\\")) {
jiveHome = jiveHome.substring(0, jiveHome.length()-1);
}
}
}
return jiveHome;
}
}
public static String getJiveProperty(String name) {
loadProperties();
// 4. 下面這句是從jive_config.xml檔案中找到屬性name的值嗎?
return properties.getProperty(name);
}


相關文章