Java ResourceBundle .containsKey (String key)

Syntax

ResourceBundle.containsKey(String key) has the following syntax.

public boolean containsKey(String key)

Example

In the following code shows how to use ResourceBundle.containsKey(String key) method.


/*from www .j  a va  2s.  com*/
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"));

      System.out.println(bundle.containsKey("bye"));

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

   }
}