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");
      }

      res.put("email", props.getProperty("email"));
      res.put("password", props.getProperty("password"));
      res.put("firstName", props.getProperty("firstName"));
      res.put("lastName", props.getProperty("lastName"));

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

    return res;

  }

}
