Skip to main content

Posts

Showing posts with the label Proprties

Properties

Java provides a feature through which a program can store and load the specific configurable data. Program can change the behavior based on the property. You can store textual information to Properties and you can use latter. Java has a class Properties that store the data in the form of hash table. Properties object is used to store or retrieve the information in the form of name-value pairs. Any string values can be stored as key/value pairs in a Properties table. However, the convention is to use a dot-separated naming hierarchy to group property names into logical structures. Working with properties First you have to create an object of the properties class. for example.             Properties prop=new Properties(); After that you can store the values by using the setter methods      prop.setProperty(“my.name”,”ABC xyz”);      prop.setProperty(“my.phone”,”878897897”); Here my.name is ...

Java : Properties Class

import java.util. * ; import java.io. * ; class PropertiesDemo { public static void main ( String ar []) { Properties prop = new Properties () ; try { prop. setProperty ( "my.name" , "ABC xyz" ) ; prop. setProperty ( "my.phone" , "3453545" ) ; FileOutputStream fout = new FileOutputStream ( "Prop.properties" ) ; prop. store ( fout, "My Properties" ) ; } catch ( Exception e ){} } } ****************************************************************************** import java.util. * ; import java.io. * ; class PropertiesDemo2 { public static void main ( String ar []) { Properties prop = new Properties () ; try...