Example usage for java.util ResourceBundle getBundle

List of usage examples for java.util ResourceBundle getBundle

Introduction

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

Prototype

@CallerSensitive
public static ResourceBundle getBundle(String baseName, Locale targetLocale, ClassLoader loader,
        Control control) 

Source Link

Document

Returns a resource bundle using the specified base name, target locale, class loader and control.

Usage

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:de.unentscheidbar.validation.swing.DefaultMessageTextGetter.java

@Override
public boolean hasText(Id messageId, Locale locale) {

    try {/*from  w w  w .  j a  v a 2  s .co  m*/
        String bundleName = getBundleName(messageId);
        ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale,
                messageId.getClass().getClassLoader(), STRICT_CONTROL);
        Object resource = bundle.getObject(messageId.name());
        return resource != null;
    } catch (MissingResourceException e) {
        return false;
    }
}