文章詳情頁(yè)
Properties 持久的屬性集的實(shí)例詳解
瀏覽:237日期:2022-06-07 09:22:30
Properties 持久的屬性集的實(shí)例詳解
特點(diǎn):
1、Hashtable的子類,map集合中的方法都可以用。
2、該集合沒(méi)有泛型。鍵值都是字符串。
3、它是一個(gè)可以持久化的屬性集。鍵值可以存儲(chǔ)到集合中,也可以存儲(chǔ)到持久化的設(shè)備(硬盤(pán)、U盤(pán)、光盤(pán))上。鍵值的來(lái)源也可以是持久化的設(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); // 從輸入流中讀取屬性列表(鍵和元素對(duì)) 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); } }
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
標(biāo)簽:
JSP
相關(guān)文章:
1. Spring導(dǎo)入properties配置文件代碼示例2. 在python中修改.properties文件的操作3. SpringBoot @ConfigurationProperties注解的簡(jiǎn)單使用4. Java 獲取properties的幾種方式5. js控制臺(tái)報(bào)錯(cuò)Uncaught TypeError: Cannot read properties of undefined (r6. idea 創(chuàng)建properties配置文件的步驟7. 基于Spring BeanUtils的copyProperties方法使用及注意事項(xiàng)8. java加載屬性配置properties文件的方法9. intellij idea中spring boot properties文件不能自動(dòng)提示問(wèn)題解決10. IDEA中application.properties的圖標(biāo)顯示不正常的問(wèn)題及解決方法
排行榜
