private static String stringReplace ( String str , String oldStr , String newStr ) { String result = "" ; int pos = str . indexOf ( oldStr ) ; // System.out.println(str + ": " + oldStr + " => " + newStr); while ( pos >= 0 ) { // System.out.println(str + " (" + pos + ")"); result += str . substring ( 0 , pos ) ; result += newStr ; str = str . substring ( pos + 1 ) ; pos = str . indexOf ( oldStr ) ; } return result + str ; }
Replace one string with another .