public CharBuffer replace(int start,int end,String string){
  int length=length();
  if (start < 0 || end < start || length < start)   throw new StringIndexOutOfBoundsException();
  int len=string.length();
  ensureCapacity(len + length - (end - start));
  char[] buffer=buffer();
  if (len < end - start) {
    int tail=length - end;
    for (int i=0; i < tail; i++) {
      buffer[start + len + i]=buffer[end + i];
    }
  }
 else {
    int tail=length - end;
    for (int i=tail - 1; i >= 0; i--) {
      buffer[end + i]=buffer[start + len + i];
    }
  }
  string.getChars(0,len,buffer,start);
  length(length + len - (end - start));
  return this;
}

public CharBuffer replace ( int start , int end , String string ) { int length = length ( ) ; if ( start < 0 || end < start || length < start ) throw new StringIndexOutOfBoundsException ( ) ; int len = string . length ( ) ; ensureCapacity ( len + length - ( end - start ) ) ; char [ ] buffer = buffer ( ) ; if ( len < end - start ) { int tail = length - end ; for ( int i = 0 ; i < tail ; i ++ ) { buffer [ start + len + i ] = buffer [ end + i ] ; } } else { int tail = length - end ; for ( int i = tail - 1 ; i >= 0 ; i -- ) { buffer [ end + i ] = buffer [ start + len + i ] ; } } string . getChars ( 0 , len , buffer , start ) ; length ( length + len - ( end - start ) ) ; return this ; }
replaces a range with a string
