Example usage for java.util ResourceBundle getString

List of usage examples for java.util ResourceBundle getString

Introduction

In this page you can find the example usage for java.util ResourceBundle getString.

Prototype

public final String getString(String key) 

Source Link

Document

Gets a string for the given key from this resource bundle or one of its parents.

Usage

From source file:Main.java

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());
    }/*from w  ww  .j  a va 2s  . c  o  m*/

}

From source file:Main.java

public static void main(String[] args) {

    ClassLoader cl = ClassLoader.getSystemClassLoader();

    ResourceBundle.Control rbc = ResourceBundle.Control.getControl(Control.FORMAT_DEFAULT);

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

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

}

From source file:MainResourceBundle.java

public static void main(String[] args) {

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

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

}

From source file:Main.java

  public static void main(String[] argv) throws Exception {

  ResourceBundle rb = ResourceBundle.getBundle("res.ResourcesDynamic", Locale.getDefault());
  System.out.println(rb.getString("title"));
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    ResourceBundle resources;

    try {/*from  w ww . j av a2 s .c  o  m*/
        resources = ResourceBundle.getBundle("MyData");
        System.out.println(resources.getString("Hi"));
    } catch (MissingResourceException mre) {
        System.err.println("MyData.properties not found");
    }
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    ResourceBundle resources;

    try {/* www.  java 2  s  .co m*/
        resources = ResourceBundle.getBundle("MyData");
        System.out.println(resources.getString("Hi"));
    } catch (MissingResourceException e) {
        e.printStackTrace();
        System.err.println("MyData.properties not found");
    }
}

From source file:Configuration.java

public static void main(String[] args) {
    ResourceBundle resource = ResourceBundle.getBundle("your.ConfigFile");
    System.out.println(resource.getObject("port"));
    System.out.println(resource.getString("host"));
}

From source file:Main.java

public static void main(String[] argv) {
    try {//w  w w .j  av  a 2  s .  c o m
        ResourceBundle rb = ResourceBundle.getBundle("SimpleResourceBundle");

        System.out.println(rb.getString("AMMessage"));
        System.out.println(rb.getString("PMMessage"));

    } catch (MissingResourceException mre) {
        mre.printStackTrace();
    }
}

From source file:RBCPTest.java

public static void main(String[] args) {
    ResourceBundle rb = ResourceBundle.getBundle("resources.XmlRB", Locale.ROOT);
    String type = rb.getString("type");
    System.out.println("Root locale. Key, type: " + type);
    System.out.println();/*  w  w  w  . j a va  2s . co  m*/

    rb = ResourceBundle.getBundle("resources.XmlRB", Locale.JAPAN);
    type = rb.getString("type");
    System.out.println("Japan locale. Key, type: " + type);
    System.out.println();

    test(Locale.CHINA);
    test(new Locale("zh", "HK"));
    test(Locale.TAIWAN);
    test(Locale.CANADA);
}

From source file:SimpleResourceBundleExample.java

  public static void main(String [] argv) {
  try {/*from  w w  w  .j  av  a2 s.co  m*/
    ResourceBundle rb = ResourceBundle.getBundle("SimpleResourceBundle");

    System.out.println(rb.getString("AMMessage"));
    System.out.println(rb.getString("PMMessage"));

  } catch (MissingResourceException mre) {
    mre.printStackTrace();
  }
}