In this section, you will learn how to get all keys and it's values of the properties files in Java.
Get All Keys and Values of the Properties files in Java
In this section, you will learn how to get all keys and it's values of the properties files in Java. Java provides the features to collection of all keys and values of the properties file. The properties files that can be used to large collections of information to be inserting in the properties files.
Here, you will get the all keys and values of the properties files with the help of this program. The program shows the keys and it's values when you run it. The following methods had been used by the program.
pro.keySet():
This method returns a set of keys, which
contained in the object of the Properties method. The Properties files has the
many keys then this method provides all keys.
pro.keys():
This method provides the all keys of the
properties files. Which stored in the Enumeration objects.
Enumeraton:
This is the interface which provided by the java.util
package. It's object implements the series of elements and calls the
nextElements method, which provides the series of elements. The keys and values
of the Properties files which is enumerated by this interface and calls the
hashtable which defines the keys and values of the properties files.
hasMoreElements():
This method checks the Enumeration object has
more elements or not and returns the true or false. It returns true, if the
Enumeration object has more than one elements Otherwise, it return false.
nextElement():
This is the method to returns the next elements
of the Enumeration, if the enumeration provides the more than one elements.
Here is the video tutorial of: "How to get key and value from properties file in Java?"
Here is the code of program:
import java.io.*;
|