@Override
    protected int updateBuffer() throws IOException {
        position = 0;

        if (closed) {
            return limit = 0;
        }

        int len = buffer.length;
        int off = 0;
        while (len > 0) {
            int read = in.read(buffer, off, len);
            if (read == -1) {
                break;
            } else {
                off += read;
                len -= read;
            }
        }
        if (copyTo != null) {
            copyTo.write(buffer, 0, off);
        }
        limit = off;
        return limit - position;
    }
Wrapper of {@link java.io.InputStream} with buffer.
clickhouse-data/src/main/java/com/clickhouse/data/stream/WrappedInputStream.java