Here you can find the source of substitute(String str, Map
public static String substitute(String str, Map<String, String> subs)
//package com.java2s; import java.util.Map; public class Main { public static String substitute(String str, Map<String, String> subs) { for (Map.Entry<String, String> e : subs.entrySet()) { String param = e.getKey(); if (str.contains(param)) str = str.replace(param, e.getValue()); }/* ww w . j av a2 s . co m*/ return str; } /** Does one string contain another string? * @param str1 * @param str2 * @return true if str1 contains str2 */ public final static boolean contains(String str1, String str2) { return str1.contains(str2); } public final static String replace(String string, String target, String replacement) { return string.replace(target, replacement); } }