Here you can find the source of replaceKeyWords(StringBuilder sb, String[] keywords, String replaceStr)
public static final StringBuilder replaceKeyWords(StringBuilder sb, String[] keywords, String replaceStr)
//package com.java2s; public class Main { public static final StringBuilder replaceKeyWords(StringBuilder sb, String[] keywords, String replaceStr) { for (int i = 0; i < keywords.length; i++) { String s = keywords[i]; for (int j = sb.indexOf(s); j > 0; j = sb.indexOf(s)) { sb.replace(j, j + s.length(), replaceStr); }/*from ww w.j a v a 2 s . c o m*/ } return sb; } }