Java Resource Message getMessage(final Locale locale, final String messageKey)

Here you can find the source of getMessage(final Locale locale, final String messageKey)

Description

get Message

License

Open Source License

Declaration

public static String getMessage(final Locale locale, final String messageKey) 

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 {
    public static String getMessage(final Locale locale, final String messageKey) {
        final ResourceBundle rb = ResourceBundle.getBundle("messages", locale);
        return rb.getString(messageKey);
    }//  w w  w . j av  a  2s. c  om

    public static String getMessage(final Locale locale, final String messageKey, final Object[] params) {
        final ResourceBundle rb = ResourceBundle.getBundle("messages", locale);
        return MessageFormat.format(rb.getString(messageKey), params);
    }
}

Related

  1. getMessage(final String bundleName, final Locale locale, final String key, final Object... params)
  2. getMessage(Locale locale, String key, Object... args)
  3. getMessage(Locale locale, String key, String... args)
  4. getMessage(Properties prop, String key, Object... args)