Here you can find the source of format(Locale locale, ResourceBundle bundle, String key, Object... args)
Parameter | Description |
---|---|
locale | the Locale (see MessageFormat#setLocale(Locale) ) |
bundle | the ResourceBundle containing the message pattern |
key | the key of the message pattern in the ResourceBundle |
args | the arguments needed for formatting the message |
public static String format(Locale locale, ResourceBundle bundle, String key, Object... args)
//package com.java2s; //License from project: Apache License import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; public class Main { /**/* w w w. j a va 2 s . co m*/ * Formats a message from the specified {@link ResourceBundle} using the specified arguments. * <p> * @param locale the {@link Locale} (see {@link MessageFormat#setLocale(Locale)}) * @param bundle the {@link ResourceBundle} containing the message pattern * @param key the key of the message pattern in the {@link ResourceBundle} * @param args the arguments needed for formatting the message * @return the formatted message */ public static String format(Locale locale, ResourceBundle bundle, String key, Object... args) { MessageFormat formatter = new MessageFormat(""); formatter.setLocale(locale); formatter.applyPattern(bundle.getString(key)); return formatter.format(args); } }