/** * @description: 加载properties文件 * @param 文件路径 * @return Properties 对象 * @author douyumeng * @throws IOException,FileNotFoundException */ public static Properties getProperties(String path){ BaseUtil bu = new BaseUtil(); String classpath = bu.getWebClassesPath(); path=classpath+path; Properties prop = new Properties(); try { InputStream in = new FileInputStream(new File(path)); prop.load(in); } catch (Exception e) { e.printStackTrace(); return null; } return prop; }
使用:
增加了size-config.properties文件
读取方法为:BaseUtil.getProperties("com/tshn/config/attachment/size-config.properties").getProperty("yourkey")