Here you can find the source of format(String source, String placeholder, Object... objs)
public static String format(String source, String placeholder, Object... objs)
//package com.java2s; import java.util.Iterator; import java.util.Map; public class Main { public static String format(String source, String placeholder, Object... objs) { for (int idx = 0; idx < objs.length; idx++) { if (source.contains(placeholder + idx) && objs[idx] != null) { source = source.replace(placeholder + idx, objs[idx].toString()); }//from ww w . jav a 2s.c o m } return source; } public static String format(String source, String placeholder, Map<String, String> formats) { Iterator<String> it = formats.keySet().iterator(); while (it.hasNext()) { String format = it.next(); if (source.contains(placeholder + format) && formats.get(format) != null) { source = source.replace(placeholder + format, formats.get(format)); } } return source; } }