国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

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

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

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);  
    }  
  }  

如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

標簽: JSP
相關文章:
主站蜘蛛池模板: 封丘县| 凤冈县| 监利县| 河北省| 尚义县| 岑巩县| 三原县| 巴林左旗| 邢台县| 射阳县| 郎溪县| 双流县| 福清市| 张掖市| 图片| 灵台县| 诸城市| 岢岚县| 若尔盖县| 普定县| 满洲里市| 云和县| 云安县| 康保县| 象州县| 阿拉善左旗| 晋城| 金川县| 福海县| 辽中县| 中牟县| 漳平市| 教育| 陆丰市| 张家港市| 邹平县| 班戈县| 屏南县| 紫阳县| 高青县| 怀安县|