Here you can find the source of replace(Map
private static String replace(Map<String, String> map, String content)
//package com.java2s; //License from project: GNU General Public License import java.util.HashMap; import java.util.Map; public class Main { private static String replace(Map<String, String> map, String content) { if (content == null) { return null; }/*from w w w.jav a2 s .c o m*/ Map<String, String> newmap = new HashMap<String, String>(); for (String key : map.keySet()) { if (map.get(key) != null) { newmap.put("${" + key + "}", map.get(key)); } } for (String key : newmap.keySet()) { String old = ""; do { old = content; content = content.replace(key, newmap.get(key)); } while (!old.equals(content)); } return content; } }