Here you can find the source of replaceCharacters(String sequence, Map
private static String replaceCharacters(String sequence, Map<String, String> map, boolean reverse)
//package com.java2s; //License from project: Open Source License import java.util.Map; import java.util.Map.Entry; public class Main { private static String replaceCharacters(String sequence, Map<String, String> map, boolean reverse) { if (reverse) { for (Entry<String, String> entry : map.entrySet()) { sequence = sequence.replace(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); }//w w w . j av a 2s .c o m } else { for (Entry<String, String> entry : map.entrySet()) { sequence = sequence.replace(String.valueOf(entry.getValue()), String.valueOf(entry.getKey())); } } return sequence; } }