Java Resource Get getResourceString(ResourceBundle rb, String key, Object param1)

Here you can find the source of getResourceString(ResourceBundle rb, String key, Object param1)

Description

Get formatted string from resource bundle

License

Apache License

Parameter

Parameter Description
rb resource bundle
key key of string in properties file
param1 first parameter

Return

formatted string

Declaration

public static String getResourceString(ResourceBundle rb, String key, Object param1) 

Method Source Code

//package com.java2s;
/*/*from   www .  j  ava 2s. c  o  m*/
 * Created 13.01.2005 at 12:57:31
 * ====================================================================
 *
 * Copyright 2004-2005 Ignat Aleksandrov, Kamil Shamgunov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

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

public class Main {
    /**
     * Get formatted string from resource bundle
     *
     * @param rb     resource bundle
     * @param key    key of string in properties file
     * @param param1 first parameter
     * @return formatted string
     */
    public static String getResourceString(ResourceBundle rb, String key, Object param1) {
        String raw = rb.getString(key);
        Object params[] = new Object[1];
        params[0] = param1;
        String formatted = MessageFormat.format(raw, params);

        return formatted;
    }
}

Related

  1. getResourceMessage(Locale locale, String resource, String key, Object... params)
  2. getResourceReader(Class clazz, String name, String charset)
  3. getResources(String archiveName)
  4. getResources(String pkgName)
  5. getResourcesFromDirectory(File resource, Pattern pattern)
  6. getResourceString(String key)
  7. getResourceString(String key, Object... args)
  8. loadResource(Class contextClass, String resourceName)
  9. loadResource(final String name)