properties in java properties file in java read properties file in java reading properties file in java
properties class in java properties class in java example system properties in java load properties file in java
loading properties file in java properties in java example properties in java example code properties file in java example reading from properties file in java example using properties class in java
Properties or Resource Bundle File :
Properties is the sub class of HashTable, so that all the methods of HashTable are inherited into Properties class. Creating properties is nothing but creating an object of properties class.
Ex : Properties p=new Properties();
Here an object p is resides in Heap memory and it is ready to hold the data in the form of (key ,value) pairs.
Definition Of Properties Class :
Properties or Resource Bundle file is text file which always organizing the data in the form (key, value) pair.
In key, value pair keys are known as property name and values are known as property values.
Profile Of Properties Class :
1) Properties() :
This constructor is used for creating the object of Properties class.
Properties p=new properties();
2) Public void Load(FileInputStream) :
This method is used for transferring or loading the content of Properties file into properties class object by opening properties file in read mode with the help of FileInputStream class.
FileInputStream fis=new FileInputStream(“Student.prop”);
3) Public String getProperty(String) :
This method is used for obtaining properties values or value of value by passing property names keys.
For Example :
Advantages of Properties Class :
Like HashTable, properties class object also maintains the user defined data in the form of (key, value) pair additional properties class will provide the following advantages compared to HashTable.
1) Properties class object is able to read the data from properties / resource bundle file.
2) Properties class object is able to read the data from environmental variables.
3) Properties class object is able to develop flexible application.
Steps or guide Lines for reading the data from Properties File :
1) Create the properties file in any editor software and save on some name with an extension of prop or rbf.
2) Open the properties file in read mode. While using pre defined class called Java.io.FileInputStream.
3) Create an object of Properties class.
4) Load / Transfer the content of properties file into properties class object.
5) Retrieve / obtain the property values of property class object by passing Properties name / keys, and display those values.
6) Close the properties file which are opened in read mode.
The Following Program Illustrate the concept of Properties Class:
Public static void main(String args)
// Step----1 Create The Properties File
FileInputStream fis=new FileInputStream(pfile);
Properties p=new Properties();
System.out.println(“Properties file does not exists”);
Systen.out.println(“PLZ ENTER THEFILE NAME”);
Data Extraction Interfaces are as follows :
1- D and 2-D Collection Frame work classes are
To read the values dynamically from keyboard their is a class.