Java Utililty Methods Resource Message

List of utility methods to do Resource Message

  1. HOME
  2. Java
  3. R
  4. Resource Message

Description

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

Method

String getMessage(final Locale locale, final String messageKey)
get Message
final ResourceBundle rb = ResourceBundle.getBundle("messages", locale);
return rb.getString(messageKey);
String getMessage(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;
...
String getMessage(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);
...
String getMessage(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;
...
String getMessage(Properties prop, String key, Object... args)
get Message
String value = prop.getProperty(key);
if (value == null)
 return null;
return MessageFormat.format(value, args);
String getMessage(Properties props, String key, Object param)
get Message
return getMessage(props, key, new Object[] { param });
String getMessage(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);
String getMessage(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;
String getMessage(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;
...
String getMessage(ResourceBundle messages, String messageKey)
Returns message as String
return messages.getString(messageKey);


AltStyle によって変換されたページ (->オリジナル) /