Here you can find the source of substituteToken(StringBuffer buf, String token, String value)
public static void substituteToken(StringBuffer buf, String token, String value)
//package com.java2s; /*/*from w w w . j a va2 s . com*/ * This file is subject to the license found in LICENCE.TXT in the root directory of the project. * * version 1.4 */ public class Main { public static String substituteToken(String pattern, String token, String value) { StringBuffer buf = new StringBuffer(pattern); substituteToken(buf, token, value); return buf.toString(); } public static void substituteToken(StringBuffer buf, String token, String value) { String from = getTokenString(token); int fromLength = from.length(); for (int index = buf.indexOf(from); index != -1; index = buf.indexOf(from, index)) { buf.replace(index, index + fromLength, value); } } public static String getTokenString(String token) { return "[" + token + "]"; } }