Java Utililty Methods Message Format

List of utility methods to do Message Format

Description

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

Method

StringformatMessage(final String pattern, final String param1)
format Message
try {
    final Object[] args = { param1 };
    return MessageFormat.format(pattern, args);
} catch (Exception e) {
    return '!' + pattern + '!';
StringformatMessage(String message, Object param1)
format Message
return formatMessage(message, new Object[] { param1 });
StringformatMessage(String message, Object... args)
format Message
MessageFormat messageFormat = new MessageFormat(message);
return messageFormat.format(args);
StringformatResource(Object[] info, String require)
format Resource
require = require.replaceAll("\'", "\"");
String result = MessageFormat.format(require, info);
return result.replaceAll("\"", "\'");
Stringformats(String pattern, Object... args)
formats
return MessageFormat.format(pattern, args);
StringformatString(ResourceBundle resourceBundle, String key, Object data)
Returns the localized string associated with a resource key and formatted with a given string.
if (resourceBundle != null) {
    try {
        String localizedStr = resourceBundle.getString(key);
        return MessageFormat.format(localizedStr, new Object[] { data });
    } catch (MissingResourceException e) {
return '[' + key + ']';
...
StringformatString(String format, String arg1)
Convenience formatting methods.
return MessageFormat.format(format, new Object[] { arg1 });
StringformatString(String message, Object... args)
Format the given message with the provided arguments.
if (args == null)
    return message;
return MessageFormat.format(message, args);
StringformatString(String str, String pattern)
format String
if (str == null)
    return "";
if (pattern == null || pattern.trim().equals("")) {
    return str;
} else {
    Object objs[] = new Object[1];
    objs[0] = str;
    return MessageFormat.format(pattern, objs);
...