將properties內容放置到map中

2021-09-01 07:26:57 字數 520 閱讀 8285

**比較簡單:

private static mapmap;

private static properties p;

static

} } catch (ioexception e)

}/**

* * 方法描述:獲取id對應的值

* * @author liming

* @time 2012-5-24 下午02:05:45

* * @param id

* @return

*/public static string getredpath(string id)

首先是讀取資源檔案,然後遍歷出所以key值,我這裡用的是set遍歷,你也可以用:

enumeration e=p.elements();

while(e.hasmoreelements())

這種方法遍歷,效果是一樣的。只要是取出key和value就可以乙個乙個放入map中了

Properties 在jar中的放置配置檔案

構造方法 public ftpconfiger 獲取ftp配置檔案全部資訊 return throws busines ception public static properties getproperties throws busines ception properties props new...

jsp中獲取properties檔案內容

如果專案中使用了struts,則有以下兩種方式 1.在struts config.xml裡配置資源檔案的 比如資源檔案叫resources.properties key labels null false key 你可以不定義 定義則在頁面顯示 不定義則 在頁面顯示 後面又找到一種方法 可以建立乙個...

讀取properties配置檔案的內容

如果配置檔案在src目錄下,用類載入器讀取 private properties pp new properties 這個是獲取xx.properties的路徑 inputstream inputstream servlet 你當前class的名字 class.getclassloader getr...