欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于java讀取并引用自定義配置文件

 更新時(shí)間:2020年06月23日 11:13:01   作者:cknds  
這篇文章主要介紹了基于java讀取并引用自定義配置文件,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

首先在resources目錄創(chuàng)建自定義的配置文件

配置文件的格式:

寫工具類,得到配置參數(shù)

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class MyConfig {
  public static Properties myProp = new Properties();
  public static InputStream myResource = MyConfig.class.getResourceAsStream("/myConfig.properties");
  static {
    try {
      myProp.load(myResource);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public String getMyConf(String props) {
    return myProp.getProperty(props);
  }
  
  public static void main(String[] args) {
    final MyConfig myConfig = new MyConfig();
    System.out.println(myConfig.getMyConf("master_ip"));
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論