RTEditor/src/main/java/com/onegravity/rteditor/utils/io/IOUtils.java
public static byte[] toByteArray(InputStream input, long size) throws IOException {

        if (size > Integer.MAX_VALUE) {
            throw new IllegalArgumentException("Size cannot be greater than Integer max value: " + size);
        }

        return toByteArray(input, (int) size);
    }
public static byte[] toByteArray(InputStream input, long size) throws IOException {

        if (size > Integer.MAX_VALUE) {
            throw new IllegalArgumentException("Size cannot be greater than Integer max value: " + size);
        }

        return toByteArray(input, (int) size);
    }
Get contents of an <code>InputStream</code> as a <code>byte[]</code>.
Use this method instead of <code>toByteArray(InputStream)</code>
when <code>InputStream</code> size is known.
<b>NOTE:</b> the method checks that the length can safely be cast to an int without truncation
before using {@link IOUtils#toByteArray(java.io.InputStream, int)} to read into the byte array.
(Arrays can have no more than Integer.MAX_VALUE entries anyway)

@param input the <code>InputStream</code> to read from
@param size  the size of <code>InputStream</code>
@return the requested byte array
@throws IOException              if an I/O error occurs or <code>InputStream</code> size differ from parameter size
@throws IllegalArgumentException if size is less than zero or size is greater than Integer.MAX_VALUE
@see IOUtils#toByteArray(java.io.InputStream, int)
@since 2.1