java引入Config文件参数

来源:互联网 发布:大数据在教育行业应用 编辑:程序博客网 时间:2024/06/06 08:55

1、

ResourceBundle rb = ResourceBundle.getBundle("config"); 
String entModal = rb.getString("entModal");


2、

String configPath = "../../../../../config.properties";

UFileConfig.getInstance().loadConfig(configPath);


public void loadConfig(String configPath) {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(configPath);
Properties configProperties = new Properties();
configProperties.load(inputStream);
this.a = configProperties.getProperty("A");
this.entModal= configProperties.getProperty("entModal");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}


原创粉丝点击