Some time ago, I went on a business trip to do a data interface project, there are a lot of parameters need to be read from the configuration file system-config.proterties file in the project, almost every class needs to be used, therefore, you should read all the configuration items in the configuration file and store them in a Map. The first thought is the singleton mode. This saves resources. After searching for some information, I started to write it and pasted the code: Java code: import java. io. file; import java. io. fileInputStream; import java. io. IOException; import java. io. inputStream; import java. util. enumeration; import java. util. hashMap; import java. util. map; import java. util. properties; public class SystemConfigUtil {private static SystemConfigUtil systemConfigUtil = null; private static Map <String, String> proMap = new HashMap <String, S Tring> (); private SystemConfigUtil () {File file = new File ("src \ system-config.properties"); InputStream is = null; Properties pro = new Properties (); try {is = new FileInputStream (file); pro. load (is); Enumeration e = pro. propertyNames (); while (e. hasMoreElements () {String key = (String) e. nextElement (); String value = (String) pro. get (key); proMap. put (key, value) ;}} catch (IOException e ){ E. printStackTrace () ;}finally {try {is. close (); // do not forget to close the resource!} Catch (IOException e) {e. printStackTrace () ;}} public static SystemConfigUtil getInstance () {if (systemConfigUtil = null) {systemConfigUtil = new SystemConfigUtil ();} return null;} public static Map <String, string> getProMap () {return proMap;} public static void main (String [] args) {// write a main method to verify SystemConfigUtil d1 = SystemConfigUtil. getInstance (); SystemConfigUtil d2 = SystemCo NfigUtil. getInstance (); System. out. println (d1 = d2); Map m1 = d1.getProMap (); Map m2 = d2.getProMap (); System. out. println (m1 = m2); System. out. println (m1.get ("ip") ;}} because it is used in a project, the configuration file is directly written to the program. A slight change can become dynamic. After testing, it takes only 2 milliseconds to read a configuration file (5 K) (on the top of my machine configuration ).