Here you can find the source of replace(String originalString, String searchString, String replaceString)
public static String replace(String originalString, String searchString, String replaceString)
//package com.java2s; public class Main { public static String replace(String originalString, String searchString, String replaceString) { StringBuilder sb = new StringBuilder(originalString); int index = sb.indexOf(searchString); while (index != -1) { sb.replace(index, index + searchString.length(), replaceString); index += replaceString.length(); index = sb.indexOf(searchString, index); }/*w w w . j av a 2 s.co m*/ return sb.toString(); } }