Java ResourceBundle.getKeys()

Syntax

ResourceBundle.getKeys() has the following syntax.

public abstract Enumeration < String > getKeys()

Example

In the following code shows how to use ResourceBundle.getKeys() method.


/*from w  w w  .  j  a va2  s.  c  om*/
import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;

public class Main {

   public static void main(String[] args) {

      ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US);

      System.out.println(bundle.getString("hello"));

      Enumeration<String>  enumeration = bundle.getKeys();

      while (enumeration.hasMoreElements()) {
         System.out.println(enumeration.nextElement());
      }

   }
}