package me.brandonc.benchmark.config; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.HashMap; import java.util.Properties; public class PropertiesBasedConfiguration extends SimpleConfiguration { public PropertiesBasedConfiguration(String filePath) { super(new HashMap<String, String>()); loadProperties(filePath); } private void loadProperties(String filePath) { Properties props = new Properties(); InputStream in = null; try { in = new BufferedInputStream(new FileInputStream(filePath)); props.load(in); Enumeration<?> en = props.propertyNames(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); String Property = props.getProperty(key); store.put(key, Property); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } }