Here you can find the source of stringReplace(String str, String what, String replacement)
public static String stringReplace(String str, String what, String replacement)
//package com.java2s; public class Main { public static String stringReplace(String str, String what, String replacement) { int i = str.indexOf(what); if (i >= 0) { int j = 0; int whatLen = what.length(); StringBuilder result = new StringBuilder(); do {// ww w.j av a 2s. com result.append(str.substring(j, i)); result.append(replacement); j = i + whatLen; i = str.indexOf(what, j); } while (i >= 0); result.append(str.substring(j)); return result.toString(); } else { return str; } } }