question: public static String replaceString ( String mainString , String oldString , String newString ) { if ( mainString == null ) { return null ; } if ( UtilValidate . isEmpty ( oldString ) ) { return mainString ; } if ( newString == null ) { newString = "" ; } int i = mainString . lastIndexOf ( oldString ) ; if ( i < 0 ) return mainString ; StringBuilder mainSb = new StringBuilder ( mainString ) ; while ( i >= 0 ) { mainSb . replace ( i , i + oldString . length ( ) , newString ) ; i = mainString . lastIndexOf ( oldString , i - 1 ) ; } return mainSb . toString ( ) ; }
target:  Replaces all occurrences of oldString in mainString with newString