@GwtIncompatible("incompatible method")
    public int readFrom(final Readable readable) throws IOException {
        final int oldSize = size;
        if (readable instanceof Reader) {
            final Reader r = (Reader) readable;
            ensureCapacity(size + 1);
            int read;
            while ((read = r.read(buffer, size, buffer.length - size)) != -1) {
                size += read;
                ensureCapacity(size + 1);
            }
        } else if (readable instanceof CharBuffer) {
            final CharBuffer cb = (CharBuffer) readable;
            final int remaining = cb.remaining();
            ensureCapacity(size + remaining);
            cb.get(buffer, size, remaining);
            size += remaining;
        } else {
            while (true) {
                ensureCapacity(size + 1);
                final CharBuffer buf = CharBuffer.wrap(buffer, size, buffer.length - size);
                final int read = readable.read(buf);
                if (read == -1) {
                    break;
                }
                size += read;
            }
        }
        return size - oldSize;
    }
@ GwtIncompatible ( "incompatible method" ) public int readFrom ( final Readable readable ) throws IOException { final int oldSize = size ; if ( readable instanceof Reader ) { final Reader r = ( Reader ) readable ; ensureCapacity ( size + 1 ) ; int read ; while ( ( read = r . read ( buffer , size , buffer . length - size ) ) != - 1 ) { size += read ; ensureCapacity ( size + 1 ) ; } } else if ( readable instanceof CharBuffer ) { final CharBuffer cb = ( CharBuffer ) readable ; final int remaining = cb . remaining ( ) ; ensureCapacity ( size + remaining ) ; cb . get ( buffer , size , remaining ) ; size += remaining ; } else { while ( true ) { ensureCapacity ( size + 1 ) ; final CharBuffer buf = CharBuffer . wrap ( buffer , size , buffer . length - size ) ; final int read = readable . read ( buf ) ; if ( read == - 1 ) { break ; } size += read ; } } return size - oldSize ; }
If possible, reads chars from the provided {@link Readable} directly into underlying
character buffer without making extra copies.

@param readable  object to read from
@return the number of characters read
@throws IOException if an I/O error occurs

@since 3.4
@see #appendTo(Appendable)