public char[] toCharArray(){
synchronized (lock) {
    char[] result=new char[count];
    System.arraycopy(buf,0,result,0,count);
    return result;
  }
}

public char [ ] toCharArray ( ) { synchronized ( lock ) { char [ ] result = new char [ count ] ; System . arraycopy ( buf , 0 , result , 0 , count ) ; return result ; } }
returns the contents of the receiver as a char array . the array returned is a copy and any modifications made to this writer after calling this method are not reflected in the result .
