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