Poperties Class in Java ::
1. Properties class is present in java.util package.
2. Properties class extends java.util.Hashtable class.
3. Property class is used to store a set of properties.These properties can be saved to a stream or file.These properties can be loaded from a stream or file.
4. Properties class is a subclass of HashTable,it stores the properties in key value format.
5. Each key and its corresponding value in the property list is a string.
6. Exception is not thrown if property is not present.
7. A property list can also contain another property list.The second property list is only searched if the property key is not found in the first property list.
8. By default the UTF-8 character encoding is used for reading from and writing to a property file, however a specific encoding may be specified if required
Method used in Properties class ::
|public String getProperty(String key)||Returns value based on the input key.|
|public void setProperty(String key,String value)||sets the key value pair property in the properties object.|
|public void load(Reader r)||Loads property data of the Property file from the Reader object.|
|public void load(InputStream is)||Loads property data of the Property file from the InputStream object|
|public void store(Writer w, String comment)||Writes property data to the Property file using Writer object.|
|public void store(OutputStream os, String comment)||Writes property data to the Property file using OutputStream object.|
|storeToXML(OutputStream os, String comment)||Writes property data to the Property file using OutputStream object for generating xml document.|
|public void storeToXML(Writer w, String comment, String encoding)||Writes property data to the Property file using Writer object.for generating xml document with specified encoding.|
How to read a property file and How To Write to a Property File .To know the answer click here.