public static void fillBuffer(final InputStream stream, final byte[] buffer, final int offset, final int len)
            throws IOException {
        final int realLen = stream.read(buffer, offset, len);

        if (realLen == -1) {
            throw new IOException("Unable to fill buffer");
        }
        if (realLen != len) {
            // Try Again
            fillBuffer(stream, buffer, offset + realLen, len - realLen);
        }
    }
Read an exact number of bytes into a buffer. Throws an exception if the
number of bytes are not available.

@param stream to read from
@param buffer to read into
@param offset to use
@param len    length
@throws IOException if error
stroom-legacy/stroom-legacy-model_6_1/src/main/java/stroom/legacy/model_6_1/StreamUtil.java