I have a properties file where the order of the values is important. I want to be able to iterate through the properties file and output the values based on the order of the
Working example :
Map properties = getOrderedProperties(new FileInputStream(new File("./a.properties")));
properties.entrySet().forEach(System.out::println);
Code for it
public Map getOrderedProperties(InputStream in) throws IOException{
Map mp = new LinkedHashMap<>();
(new Properties(){
public synchronized Object put(Object key, Object value) {
return mp.put((String) key, (String) value);
}
}).load(in);
return mp;
}