版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010741376/article/details/44678489
properties配置文件:
username=mike
pwd=123
public class UtilBundle{
public static String getValue(String username,String pwd){
ResourceBundle resource=ResourceBundle.getBundle("config");//根据ResourceBundle类来读取配置文件中信息
if(resource!=null){
username=resource.getString(username);//通过getString()方法获取value的值
pwd=resource.getString(pwd);
}else{
username=null;
pwd=null;
}
return username+","+pwd;
}
}
public class TestBundle {
public static void main(String[] args) {
String value=UtilBundle.getValue("username","pwd");
System.out.println("value:"+value);
}
}