private String substituteSubString(String input,String find,String replace){
  int find_length=find.length();
  int replace_length=replace.length();
  StringBuilder output=new StringBuilder(input);
  int index=input.indexOf(find);
  int outputOffset=0;
  while (index > -1) {
    output.replace(index + outputOffset,index + outputOffset + find_length,replace);
    outputOffset=outputOffset + (replace_length - find_length);
    index=input.indexOf(find,index + find_length);
  }
  return output.toString();
}

private String substituteSubString ( String input , String find , String replace ) { int find_length = find . length ( ) ; int replace_length = replace . length ( ) ; StringBuilder output = new StringBuilder ( input ) ; int index = input . indexOf ( find ) ; int outputOffset = 0 ; while ( index > - 1 ) { output . replace ( index + outputOffset , index + outputOffset + find_length , replace ) ; outputOffset = outputOffset + ( replace_length - find_length ) ; index = input . indexOf ( find , index + find_length ) ; } return output . toString ( ) ; }
replace substrings of one string with another string and return altered string .
