Java Utililty Methods Resource Message

List of utility methods to do Resource Message

Description

The list of methods to do Resource Message are organized into topic(s).

Method

StringgetMessage(final Locale locale, final String messageKey)
get Message
final ResourceBundle rb = ResourceBundle.getBundle("messages", locale);
return rb.getString(messageKey);
StringgetMessage(final String bundleName, final Locale locale, final String key, final Object... params)
Get a message from a resource bundle present in classpath.
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale, classLoader);
String text = bundle.getString(key);
if (params != null) {
    final MessageFormat mf = new MessageFormat(text, locale);
    text = mf.format(params, new StringBuffer(), null).toString();
return text;
...
StringgetMessage(Locale locale, String key, Object... args)
Returns a message formated in the specified locale.
ResourceBundle resources = ResourceBundle.getBundle("messages", locale);
String message = null;
try {
    message = resources.getString(key);
} catch (MissingResourceException e) {
    message = "**" + key + "**";
return MessageFormat.format(message, args);
...
StringgetMessage(Locale locale, String key, String... args)
get Message
if (locale != null) {
    messageRb = ResourceBundle.getBundle(RESOURCEMESSAGE, locale);
} else {
    messageRb = ResourceBundle.getBundle(RESOURCEMESSAGE);
MessageFormat msgFormat = new MessageFormat(messageRb.getString(key));
Object[] arguments = new Object[args.length];
int i = 0;
...
StringgetMessage(Properties prop, String key, Object... args)
get Message
String value = prop.getProperty(key);
if (value == null)
    return null;
return MessageFormat.format(value, args);
StringgetMessage(Properties props, String key, Object param)
get Message
return getMessage(props, key, new Object[] { param });
StringgetMessage(ResourceBundle bundle, Object key, Object[] params)
get Message
String pattern = bundle.getString(key.toString());
if ((params == null) || (params.length == 0)) {
    return pattern;
return MessageFormat.format(pattern, params);
StringgetMessage(ResourceBundle bundle, String key, Object... params)
get Message
if (bundle == null || key == null) {
    return key;
try {
    return formatMessage(bundle.getString(key), params);
} catch (MissingResourceException e) {
    return key;
StringgetMessage(ResourceBundle bundle, String key, Object... params)
Get the i18n string message with an associated resource bundle
String fmt = null;
try {
    if (null == bundle) {
        return key;
    fmt = bundle.getString(key);
} catch (MissingResourceException ex) {
    return key;
...
StringgetMessage(ResourceBundle messages, String messageKey)
Returns message as String
return messages.getString(messageKey);