private static ResourceBundle property= ResourceBundle.getBundle("properties/" + "/address");
//通过key值获取对应的value值
public static String get(String key) {
if(property == null) {
throw new IllegalArgumentException("[address.properties] is not found!");
} else {
try {
String value = new String(property.getString(key).getBytes("ISO-8859-1"),"utf-8").trim();
return value;
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage());
e.printStackTrace();
}
}
throw new IllegalArgumentException("parameter is not found!");
}
ResourceBundle读取配置文件
最新推荐文章于 2023-08-14 22:29:50 发布