久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Properties 持久的屬性集的實例詳解

瀏覽:269日期:2022-06-07 09:22:30

Properties 持久的屬性集的實例詳解

特點:

1、Hashtable的子類,map集合中的方法都可以用。

2、該集合沒有泛型。鍵值都是字符串。

3、它是一個可以持久化的屬性集。鍵值可以存儲到集合中,也可以存儲到持久化的設備(硬盤、U盤、光盤)上。鍵值的來源也可以是持久化的設備。

// 根據(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ū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

標簽: JSP
相關文章:
主站蜘蛛池模板: 交城县| 勐海县| 泾川县| 图木舒克市| 沙湾县| 额敏县| 伊吾县| 察隅县| 彭山县| 汉沽区| 扎兰屯市| 府谷县| 广河县| 射洪县| 始兴县| 岳西县| 嘉义县| 若尔盖县| 黄浦区| 新乐市| 自治县| 含山县| 高陵县| 项城市| 米泉市| 定结县| 黑河市| 台前县| 江津市| 曲水县| 哈密市| 石屏县| 武威市| 东辽县| 宝清县| 阳原县| 南宁市| 华蓥市| 金华市| 依安县| 威远县|