Example #1
0
 public void writeProperties(Map<?, ?> properties) {
   Properties props = new Properties();
   props.putAll(properties);
   try {
     FileOutputStream stream = new FileOutputStream(this);
     try {
       props.store(stream, "comment");
     } finally {
       stream.close();
     }
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
Example #2
0
 public Map<String, String> getProperties() {
   assertIsFile();
   Properties properties = new Properties();
   try {
     FileInputStream inStream = new FileInputStream(this);
     try {
       properties.load(inStream);
     } finally {
       inStream.close();
     }
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   Map<String, String> map = new HashMap<String, String>();
   for (Object key : properties.keySet()) {
     map.put(key.toString(), properties.getProperty(key.toString()));
   }
   return map;
 }