public class PropertyUtil {
private static Properties prop = new Properties();
static {
try {
prop.load(PropertyUtil.class.getClassLoader().getResourceAsStream(“calculator.properties”));
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}
/**
* 根据Name获取Property
* @param name
* @return
/
public static String getProperty(String name) {
return prop.getProperty(name);
}
/*
* 获取所有的Property
* @return
*/
public static List getBeanFactoryClass() {
List list = new ArrayList<>();
Set keys = prop.stringPropertyNames();
for (String key : keys) {
list.add(prop.getProperty(key));
}
return list;
}
}
封装的PropertiesUtil工具类:
最新推荐文章于 2025-03-29 23:13:22 发布