Properties 持久的屬性集的實例詳解
properties 持久的屬性集的實例詳解
特點:
1、hashtable的子類,map集合中的方法都可以用。
2、該集合沒有泛型。鍵值都是字符串。
3、它是一個可以持久化的屬性集。鍵值可以存儲到集合中,也可以存儲到持久化的設備(硬盤、u盤、光盤)上。鍵值的來源也可以是持久化的設備。
// 根據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ū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關文章
- jsp+servlet實現文件上傳與下載功能
- EJB3.0部署消息驅動Bean拋javax.naming.NameNotFoundException異常
- 在JSP中使用formatNumber控制要顯示的小數位數方法
- 秒殺系統(tǒng)Web層設計的實現方法
- 將properties文件的配置設置為整個Web應用的全局變量實現方法
- JSP使用過濾器防止Xss漏洞
- 在JSP頁面中動態(tài)生成圖片驗證碼的方法實例
- 詳解JSP 內置對象request常見用法
- 使用IDEA編寫jsp時EL表達式不起作用的問題及解決方法
- jsp實現局部刷新頁面、異步加載頁面的方法
- Jsp中request的3個基礎實踐
- JavaServlet的文件上傳和下載實現方法
- JSP頁面的靜態(tài)包含和動態(tài)包含使用方法