【发布时间】:2017-04-03 19:29:32
【问题描述】:
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
public class TestTokenReplacement {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
String message = "this/is/{bad}";
map.put("bad", "good");
System.out.println(MessageFormat.format(message, map.get("bad")));
}
}
预期输出是:this/is/good 如何格式化字符串以替换 Map 中的字符串标记?
【问题讨论】:
标签: java text-formatting