package helpers;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class GetAccountProperties {
  InputStream inputStream;

  public Map<String, String> getProps() throws IOException {
    Map<String, String> res = new HashMap<>();

    try {
      Properties props = new Properties();
      String propFileName = "account.properties";
      inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);

      if (inputStream != null) {
        props.load(inputStream);
      } else {
        throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
      }

      props.stringPropertyNames().forEach(prop -> {
        res.put(prop, props.getProperty(prop));
      });

    } catch (Exception e) {
      System.out.println(e);
    } finally {
      inputStream.close();
    }

    return res;

  }

}
