主頁 > 知識庫 > Properties 持久的屬性集的實例詳解

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

熱門標簽:Mysql連接數(shù)設(shè)置 銀行業(yè)務(wù) 團購網(wǎng)站 電子圍欄 服務(wù)器配置 Linux服務(wù)器 科大訊飛語音識別系統(tǒng) 阿里云

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

您可能感興趣的文章:
  • spring boot中的properties參數(shù)配置詳解
  • java簡單讀取properties配置文件的方法示例
  • MyBatis Properties及別名定義實例詳解
  • java web開發(fā)中獲取tomcat上properties文件內(nèi)容的方法
  • Java讀取Properties文件的七種方法的總結(jié)
  • spring boot application properties配置實例代碼詳解
  • Java 操作Properties配置文件詳解
  • .properties文件讀取及占位符${...}替換源碼解析

標簽:蚌埠 江蘇 萍鄉(xiāng) 衢州 衡水 棗莊 大理 廣元

巨人網(wǎng)絡(luò)通訊聲明:本文標題《Properties 持久的屬性集的實例詳解》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266