获取 .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;
 }

你可能感兴趣的:(获取 .properties 配置文件中的值)