class="java"> private static final String FILENAME = "dll/service.properties"; private static Properties properties = null; //静态块 static{ properties = new Properties(); InputStream in = null; try { //读取服务文件 in = new FileInputStream(FILENAME); properties.load(in); } catch (IOException e) { ErrorPrint.sprintLog(e, log,"加载service.properties配置文件"); e.printStackTrace(); }finally{ try { in.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } /** * 获取service.properties文件 * @param key * @return */ public static String getPropertiesValue(String key){ if (properties.containsKey(key)) { String value = properties.getProperty(key);// 得到某一属性的值 return value; } else return ""; }
?