public static String replaceSubstring(String inString,String subString,String replaceString){
  StringBuffer result=new StringBuffer();
  int oldLoc=0, loc=0;
  while ((loc=inString.indexOf(subString,oldLoc)) != -1) {
    result.append(inString.substring(oldLoc,loc));
    result.append(replaceString);
    oldLoc=loc + subString.length();
  }
  result.append(inString.substring(oldLoc));
  return result.toString();
}

public static String replaceSubstring ( String inString , String subString , String replaceString ) { StringBuffer result = new StringBuffer ( ) ; int oldLoc = 0 , loc = 0 ; while ( ( loc = inString . indexOf ( subString , oldLoc ) ) != - 1 ) { result . append ( inString . substring ( oldLoc , loc ) ) ; result . append ( replaceString ) ; oldLoc = loc + subString . length ( ) ; } result . append ( inString . substring ( oldLoc ) ) ; return result . toString ( ) ; }
replaces with a new string , all occurrences of a string from another string .
