Detailed Properties class in Java

What 1.Properties class is?

Properties (Java.util.Properties), Java class is mainly used to read the configuration file, different programming languages ​​have their own supported profiles, profiles many variables are constantly changing, in order to facilitate the user's configuration, can allowing users to modify the program itself enough from the relevant variable settings. Parameter configuration like in Java, its configuration file often .properties file, in the form of key-value pairs.

2. The common approach

getProperty (String key) in this property list, search for a property with the specified key. If you can not find the key in this property list, the default property list is checked and their default values ​​(recursively). If the property is not found, the method returns the default value of the parameter.

list (PrintStream out) this printing attribute list to the specified output stream. This method is useful for debugging.

load (InputStream inStream) Reads a property list (key and element pairs) from the input byte stream. Loading the format input stream (Reader) specified in a simple line-oriented, and assuming use ISO 8859-1 character encoding; Latin1 i.e., each byte is a character. Not Latin1 characters and some special characters and indicates the key element in Unicode escapes. After this method returns, specified stream remains open.

setProperty (String key, String value) calls the Hashtable method put. He set the key-value pair by calling the put method of the base class.

store (OutputStream out, String comments) This attribute this list (key and element pairs) Properties of the table suitably used to load (InputStream) Method Properties sheet format is loaded into the output stream. This method does not write the defaults Properties Properties Table This table attributes (if any).

storeToXML (OutputStream os, String comment, String encoding) using the specified encoding Emits an XML document in this table contains all the attributes.

clear () Clear the hash table so that it does not contain any keys.

stringPropertyNames () Returns a property list in this set of keys, wherein the key and the corresponding value is a string, if the key has not been found from the main properties of the same name in the list, the list including default property different key. Key or key is not a property of type String will be omitted.

Guess you like

Origin www.cnblogs.com/qqyy/p/12051554.html