The configuration file in Java is usually the properties file, in the form of a text file, and the format of the file content is "key = value" format. Note information is annotated with "#".
Common methods of properties class
| String GetProperty (String key) |
Searches for a property in this property list with the specified key. Get the value of the parameter key |
| Object setProperty (String key,string value) |
Call the Hashtable method put. Set a key-value pair by calling the put () method of the base class |
| void load (InputStream instream) |
Reads the list of attributes (key and element pairs) from the input stream. Gets all the key-value pairs in the file by loading the specified file |
| void Clear () |
Clears the loaded key-value pair, which is provided by the base class Hashtable |
Gets the input stream for the specified path file:
ClassName. class. getClassLoader (). getResourceAsStream (Configurepath)
Java Properties Configuration file