Package Util;import java.io.ioexception;import java.io.inputstream;import java.util.properties;/** * Get profile information * * @ Author Carl */public Final class GetProperties {private static Properties prop = Null;static{prop = new Properties ();//Set The properties file path, with SRC as the root path (config.properties in src root) inputstream in = GetProperties.class.getResourceAsStream ("/ Config.properties "); try {prop.load (in);} catch (IOException e) {System.out.println (" read config file failed---->>>>--- -(/src/config.properties) "); E.printstacktrace ();}} /** * Gets the corresponding value in the configuration file according to the key passed in * @param key * @return */public static string Getpropertievalue (String key) {String value = ""; VA Lue = Prop.getproperty (key). Trim (); return value;}}
Read the properties file in the Java project