举例:jdk中读取properties文件中的操作
ResourceBundle resourceBundle = ResourceBundle.getBundle("test");
Enumeration<String> keys = resourceBundle.getKeys();
while (keys.hasMoreElements()) {
String s = keys.nextElement();
String bundleString = resourceBundle.getString(s);
System.out.println(bundleString);
}
hutool工具包读取proproties 文件的操作
Props props = PropsUtil.get("test");
Enumeration<Object> keys = props.keys();
while (keys.hasMoreElements()) {
Object o = keys.nextElement();
Object o1 = props.get(o);
System.out.println(o1);
}
hutool工具包可以操作资源文件(例如:.properties,.xml等)
Resource resourceObj = ResourceUtil.getResourceObj("test.properties");
String readUtf8Str = resourceObj.readUtf8Str();
String readUtf8Str1 = ResourceUtil.readUtf8Str("test.properties");