封装的PropertiesUtil工具类:

    xiaoxiao2022-07-12  158

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

    最新回复(0)