Java API Tutorial - 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.

/*www.  jav  a  2 s .  c  o m*/
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());
      }

   }
}