private boolean readable(final int minimum) throws IOException
    {
        int existing = limit - offset;
        final int available = buffer.length - limit;

        if (minimum > available + existing)
        {
            // move to front.
            System.arraycopy(buffer, offset, buffer, 0, existing);
            offset = 0;
            limit = existing;

            int read;
            do
            {
                read = in.read(buffer, limit, buffer.length - limit);
                if (read == -1)
                    return false;

                limit += read;
                existing += read;
            } while (existing < minimum);

            return true;
        }

        int read;
        do
        {
            read = in.read(buffer, limit, buffer.length - limit);
            if (read == -1)
                return false;

            limit += read;
            existing += read;
        } while (existing < minimum);

        return true;
    }
Returns true if there are {@code minimum} bytes available for reading.
<p>
The caller is responsible that the arg {@code minimum} is not larger than the buffer size.
protostuff-kvp/src/main/java/io/protostuff/KvpInput.java