public static String replace(String original,String oldSubstring,String newSubstring,boolean all){
  StringBuffer b=new StringBuffer(original);
  replace(b,oldSubstring,newSubstring,all);
  return b.toString();
}

public static String replace ( String original , String oldSubstring , String newSubstring , boolean all ) { StringBuffer b = new StringBuffer ( original ) ; replace ( b , oldSubstring , newSubstring , all ) ; return b . toString ( ) ; }
returns original with occurrences of oldsubstring replaced by newsubstring . set all to true to replace all occurrences , or false to replace the first occurrence only .
