Here you can find the source of formatString(String str, String pattern)
public static String formatString(String str, String pattern)
//package com.java2s; //License from project: Apache License import java.text.MessageFormat; public class Main { public static String formatString(String str, String pattern) { if (str == null) return ""; if (pattern == null || pattern.trim().equals("")) { return str; } else {/*from w ww .j a v a 2s . c o m*/ Object objs[] = new Object[1]; objs[0] = str; return MessageFormat.format(pattern, objs); } } }