Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

save map to file java

// 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);

// Load the map
Map<String, String> map_from_file = new HashMap<String, String>();
Properties properties = new Properties();
properties.load(new FileInputStream("data.properties"));

for (String key : properties.stringPropertyNames()) {
   map_from_file.put(key, properties.get(key).toString());
}
Comment

PREVIOUS NEXT
Code Example
Java :: import android.support.v4.app.ActivityCompat; 
Java :: spigot cancel repeating task 
Java :: java save file dialog 
Java :: read text file java to string 
Java :: jcenter is at end of life 
Java :: junit 5 dependency maven 
Java :: find maven version 
Java :: handler delay android 
Java :: spring cors allow all origins 
Java :: springboot starter jpa 
Java :: flutter Uri toString and String to Uri 
Java :: base64 decode java 
Java :: java cwd 
Java :: equivalent to params keyword in java 
Java :: exit app android 
Java :: convert string to list java 8 
Java :: java random max and min 
Java :: print up to 2 decimal in java 
Java :: add label gui jframe java 
Java :: java yesterday date 
Java :: resultset get value 
Java :: flutter request location permission 
Java :: fullscreen java jframe 
Java :: convert string to double android studio 
Java :: convert object to map scala 
Java :: check if char is in char array java 
Java :: program in java. Get a string from user and also validate it’s length should be at least 1. Pass this string to a method that returns a new string with the first char added at the front and end, so "cat" yields "ccatc". 
Java :: android java string to double 
Java :: how to write custom message for repeat password in joi 
Java :: java string lowercase 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =