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.
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.
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.*; import java.util.*; public class GetAllProperties < |
Tutorials
- Java util package Examples
- Java Util Package — Utility Package of Java
- Generating Random Number
- Breaking the String into Words
- Listing all available Locales
- Setting the default Locale
- Associate a value with an object
- Comparing Arrays
- Shuffling the Element of a List or Array
- Collections Framework
- Collection Iterate Example
- Converting Collection to an Array
- Converting an Array to a Collection
- Implement the Queue in Java
- Implementing a Stack in Java
- Implementing a Least-Recently-Used(LRU) Cache
- Creating a Copy of a Collection
- Making a Collection Read-Only
- Sorting elements of a Collection
- Creating a Hash Table
- Finding an Element in a Sorted Array
- Read the Key-Value of Property File in Java
- Get All Keys and Values of the Properties files in Java
- Write the Keys and Values of the Properties files in Java
- Scheduling a Timer Task
- Getting the Current Time
- Getting Information of All Available Time Zones
- Getting the current date
- Determining the Number of Days in a Month
- Comparing Dates in Java
- Determining the actual age from date of birth in Java
- Determining If a Year is a Leap Year in Java
- Determining the Day-of-Week for a Particular Date
- What is a JAR file in Java
- Creating a JAR file in Java
- Viewing contents of a JAR File
- Listing the Main Attributes in a JAR File Manifest
- Creating a ZIP file in Java
- Listing Contents of a ZIP File
- Unzip a ZIP File