Home » Java programming language

Java PropertyResourceBundle getKeys() Method with Example

PropertyResourceBundle Class getKeys() method: Here, we are going to learn about the getKeys() method of PropertyResourceBundle Class with its syntax and example.
Submitted by Preeti Jain, on March 21, 2020

PropertyResourceBundle Class getKeys() method

  • getKeys() method is available in java.util package.
  • getKeys() method is used to return an enumeration of the keys that exist in this PropertyResourceBundle and its parent.
  • getKeys() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • getKeys() method does not throw an exception at the time of returning the key set.

Syntax:

    public Enumeration getKeys();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of the method is Enumeration, it gets an enumeration of the existing keys of this PropertyResourceBundle and its super class.

Example:

// Java program to demonstrate the example 
// of Enumeration getKeys() method of 
//  PropertyResourceBundle

import java.io.*;
import java.util.*;

public class GetKeyOfPropertyResourceBundle {
 public static void main(String arg[]) throws Exception {
  // Instantiate Properties object
  String str = "10 = C\n" + " 20 =C++\n " + " 30 =Java\n ";
  InputStream is = new StringBufferInputStream(str);

  PropertyResourceBundle prb = new PropertyResourceBundle(is);
  Enumeration en = prb.getKeys();

  for (; en.hasMoreElements();)
   System.out.println(en.nextElement());
 }
}

Output

30
20
10





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.