Here you can find the source of getMessageString(String bundleName, String key, Object[] params, Locale locale)
public static String getMessageString(String bundleName, String key, Object[] params, Locale locale)
//package com.java2s; /*/*from w w w .j ava2 s. c o m*/ * Copyright (c) 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Nuxeo - initial API and implementation * * $Id: I18NUtils.java 19046 2007-05-21 13:03:50Z sfermigier $ */ import java.text.MessageFormat; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; public class Main { public static String getMessageString(String bundleName, String key, Object[] params, Locale locale) { String text; ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale, getCurrentClassLoader(params)); try { text = bundle.getString(key); } catch (MissingResourceException e) { text = key; } if (params != null) { MessageFormat mf = new MessageFormat(text, locale); text = mf.format(params, new StringBuffer(), null).toString(); } return text; } static ClassLoader getCurrentClassLoader(Object defaultObject) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { loader = defaultObject.getClass().getClassLoader(); } return loader; } }