操作属性文件

// 取得属性文件中
 private Map<String, String> getPropertiesMap() {
  Properties properties = new Properties();
  try {
   properties.load(this.getClass().getClassLoader()
     .getResourceAsStream("jdbc.properties"));
   alertConfigMap.put("jdbc.url", properties.getProperty("jdbc.url"));
   alertConfigMap.put("jdbc.url.3d", properties.getProperty("jdbc.url.3d"));
   alertConfigMap.put("jdbc.username", properties.getProperty("jdbc.username"));
   alertConfigMap.put("jdbc.password", properties.getProperty("jdbc.password"));
   
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  return alertConfigMap;
 }

你可能感兴趣的:(properties,String)