读取properties文件(项目中的配置文件)

    技术2025-08-09  10

    String propPath = "/com/enn/cpm/settings/subjectpage/"+hptype+".properties"; Properties p =  new Properties(); try {  //读取配置文件  InputStream stream = Controller.class.getResourceAsStream(propPath);  if (stream != null)  p.load(stream);  } catch (IOException e) {        e.printStackTrace();     }  //从配置文件中获得配置信息 String url = (String)p.get("frame"+i+"URL"); if(hostInfo.length>0&&(!"".equals(url))&&url != null&&url.indexOf("[host]")!=-1) url = url.replaceAll("//[host//]", hostInfo[2]); 

     

    获取getResourceAsStream   可以通过 所在类的类名.class.getResourceAsStream(..)

    最新回复(0)