获取 .properties 配置文件中的值

public static String getPath() {
  String path = "";
  Properties prop = new Properties();
        try {
         InputStream in = ImageURL.class.getClassLoader().getResourceAsStream("jdbc.properties");
            prop.load(in);
            
            path = prop.getProperty("admin.path");
            
            in.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return path;
 }

版权声明:本文为博主原创文章,未经博主允许不得转载。

原文地址:https://www.cnblogs.com/shipeng22022/p/4614110.html