Here you can find the source of replaceSeparator(String value, String separator, Map
public static String replaceSeparator(String value, String separator, Map<String, String> map)
//package com.java2s; //License from project: Open Source License import java.util.Map; public class Main { public static String replaceSeparator(String value, String separator, Map<String, String> map) { if (map == null || map.size() == 0) { return value; }/*from w ww . j av a2s.c o m*/ StringBuilder sb = new StringBuilder(); String[] valueSplit = value.split(separator); for (int i = 0; i < valueSplit.length; i++) { String replace = map.get(valueSplit[i]); if (null != replace && !"".equals(replace)) { sb.append(replace); } else { sb.append(valueSplit[i]); } if (i < valueSplit.length - 1) { sb.append(separator); } } return sb.toString(); } }