public static String replaceString(String originalString,String token,String newString){
  int lenToken=token.length();
  int idx=originalString.indexOf(token);
  while (idx != -1) {
    originalString=originalString.substring(0,idx) + newString + originalString.substring(idx + lenToken);
    idx=originalString.indexOf(token,idx + lenToken);
  }
  return originalString;
}

public static String replaceString ( String originalString , String token , String newString ) { int lenToken = token . length ( ) ; int idx = originalString . indexOf ( token ) ; while ( idx != - 1 ) { originalString = originalString . substring ( 0 , idx ) + newString + originalString . substring ( idx + lenToken ) ; idx = originalString . indexOf ( token , idx + lenToken ) ; } return originalString ; }
replaces a string with another string in a string object .
