Java Resource Message getMessage(String key, Object... contents)

Here you can find the source of getMessage(String key, Object... contents)

Description

get Message

License

Open Source License

Declaration

public static String getMessage(String key, Object... contents) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class Main {
    private static ResourceBundle bundle = ResourceBundle.getBundle(
            "message", Locale.US);

    public static String getMessage(String key, Object... contents) {
        try {//from w  ww . ja v a 2  s.c  om
            String msg = bundle.getString(key);
            return MessageFormat.format(msg, contents);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
}

Related

  1. getMessage(ResourceBundle messages, String msgKey, Object[] arguments)
  2. getMessage(String bundleName, Locale locale, String key, String defaultMsg)
  3. getMessage(String key)
  4. getMessage(String key)
  5. getMessage(String key)
  6. getMessage(String key, Object... values)
  7. getMessage(String key, String... fill)
  8. getMessage(String messageKey)
  9. getMessage(String messageKey, Object[] params)