code: private static CharBuffer grow(CharBuffer buf) {
      char[] copy = Arrays.copyOf(buf.array(), buf.capacity() * 2);
      CharBuffer bigger = CharBuffer.wrap(copy);
      bigger.position(buf.position());
      bigger.limit(buf.limit());
      return bigger;
    }
docs: Returns a new CharBuffer identical to buf, except twice the capacity.