public void write(String str, int off, int len) {
        int newcount = count + len;
        if (newcount > buf.length) {
            if (writer == null) {
                expandCapacity(newcount);
            } else {
                do {
                    int rest = buf.length - count;
                    str.getChars(off, off + rest, buf, count);
                    count = buf.length;
                    flush();
                    len -= rest;
                    off += rest;
                } while (len > buf.length);
                newcount = len;
            }
        }
        str.getChars(off, off + len, buf, count);
        count = newcount;
    }
Write a portion of a string to the buffer.

@param str String to be written from
@param off Offset from which to start reading characters
@param len Number of characters to be written
src/main/java/com/alibaba/fastjson/serializer/SerializeWriter.java