Properties 持久的屬性集的實例詳解
properties 持久的屬性集的實例詳解
特點:
1、hashtable的子類,map集合中的方法都可以用。
2、該集合沒有泛型。鍵值都是字符串。
3、它是一個可以持久化的屬性集。鍵值可以存儲到集合中,也可以存儲到持久化的設(shè)備(硬盤、u盤、光盤)上。鍵值的來源也可以是持久化的設(shè)備。
// 根據(jù)key讀取value public void readvalue(string filepath, string key) { properties props = new properties(); inputstream in = new bufferedinputstream(new fileinputstream(filepath)); //thread.currentthread().getcontextclassloader().getresourceasstream("eop.properties"); props.load(in); // 從輸入流中讀取屬性列表(鍵和元素對) string value = props.getproperty(key); } // 讀取properties的全部信息 public static void readproperties(string filepath) { properties props = new properties(); inputstream in = new bufferedinputstream(new fileinputstream(filepath)); props.load(in); enumeration en = props.propertynames(); while (en.hasmoreelements()) { string key = (string) en.nextelement(); string value = props.getproperty(key); } }
如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
- jsp+servlet實現(xiàn)文件上傳與下載功能
- EJB3.0部署消息驅(qū)動Bean拋javax.naming.NameNotFoundException異常
- 在JSP中使用formatNumber控制要顯示的小數(shù)位數(shù)方法
- 秒殺系統(tǒng)Web層設(shè)計的實現(xiàn)方法
- 將properties文件的配置設(shè)置為整個Web應(yīng)用的全局變量實現(xiàn)方法
- JSP使用過濾器防止Xss漏洞
- 在JSP頁面中動態(tài)生成圖片驗證碼的方法實例
- 詳解JSP 內(nèi)置對象request常見用法
- 使用IDEA編寫jsp時EL表達式不起作用的問題及解決方法
- jsp實現(xiàn)局部刷新頁面、異步加載頁面的方法
- Jsp中request的3個基礎(chǔ)實踐
- JavaServlet的文件上傳和下載實現(xiàn)方法
- JSP頁面的靜態(tài)包含和動態(tài)包含使用方法