Save map in file
Map<string, string=""> map = new HashMap<string, string="">();
Properties properties = new Properties();
for (Map.Entry<string,string> entry : map.entrySet()) {
properties.put(entry.getKey(), entry.getValue());
}
properties.store(new FileOutputStream("data.properties"), null);
</string,string></string,></string,>
Map<string, string=""> map = new HashMap<string, string="">();
Properties properties = new Properties();
for (Map.Entry<string,string> entry : map.entrySet()) {
properties.put(entry.getKey(), entry.getValue());
}
properties.store(new FileOutputStream("data.properties"), null);
</string,string></string,></string,>
Mapmap = new HashMap (); Properties properties = new Properties(); for (Map.Entry entry : map.entrySet()) { properties.put(entry.getKey(), entry.getValue()); } properties.store(new FileOutputStream("data.properties"), null);
Load map from file
Map<string, string=""> mapFromFile = new HashMap<string, string="">();
Properties properties = new Properties();
properties.load(new FileInputStream("data.properties"));
for (String key : properties.stringPropertyNames()) {
mapFromFile.put(key, properties.get(key).toString());
}
</string,></string,>
Map<string, string=""> mapFromFile = new HashMap<string, string="">();
Properties properties = new Properties();
properties.load(new FileInputStream("data.properties"));
for (String key : properties.stringPropertyNames()) {
mapFromFile.put(key, properties.get(key).toString());
}
</string,></string,>
MapmapFromFile = new HashMap (); Properties properties = new Properties(); properties.load(new FileInputStream("data.properties")); for (String key : properties.stringPropertyNames()) { mapFromFile.put(key, properties.get(key).toString()); }