I want to populate a HashMap
using the Properties
class.
I want to load the entries in the .propeties
file and then copy it into
you can use the below Method to load the property file in a map
public static Map getProperties(String filePropertyFile){
Properties getProperties = new Properties();
FileInputStream inputStream = null;
HashMap propertyMap = new HashMap();
try {
inputStream = new FileInputStream(filePropertyFile);
getProperties.load(inputStream);
propertyMap.putAll((Map) getProperties);
} catch (Exception e) {
e.printStackTrace();
}
return propertyMap;
}
Unit Test:
@Test
public void getPropertiesTest()
String outputOmJarArrayAttributesPath = System.getProperty("user.dir") + "/src/main/resources/OutputOmJarArrayAttributes.properties";
System.out.println(PropertyFileUtils.getProperties(outputOmJarArrayAttributesPath));;
}