public char[] toCharArray() {
    char newbuf[] = new char[size()];
    System.arraycopy(buf, 0, newbuf, 0, size());
    return newbuf;
  }
A StringBuilder that allows one to access the array.
linguistics/src/main/java/com/yahoo/language/simple/kstem/OpenStringBuilder.java