mayi-common/mayi-common-core/src/main/java/com/zf1976/mayi/common/core/util/IOUtil.java
public static int readFully(final InputStream input, final byte[] array, final int offset, final int len)
            throws IOException {
        if (len < 0 || offset < 0 || len + offset > array.length || len + offset < 0) {
            throw new IndexOutOfBoundsException();
        }
        int count = 0, x = 0;
        while (count != len) {
            x = input.read(array, offset + count, len - count);
            if (x == -1) {
                break;
            }
            count += x;
        }
        return count;
    }
/**
     * Reads as much from input as possible to fill the given array
     * with the given amount of bytes.
     *
     * <p>This method may invoke read repeatedly to read the bytes and
     * only read less bytes than the requested length if the end of
     * the stream has been reached.</p>
     *
     * @param input  stream to read from
     * @param array  buffer to fill
     * @param offset offset into the buffer to start filling at
     * @param len    of bytes to read
     * @return the number of bytes actually read
     * @throws IOException if an I/O error has occurred
     */
Reads as much from input as possible to fill the given array
with the given amount of bytes.

This method may invoke read repeatedly to read the bytes and
only read less bytes than the requested length if the end of
the stream has been reached.


Reads as much from input as possible to fill the given array with the given amount of bytes . This method may invoke read repeatedly to read the bytes and only read less bytes than the requested length if the end of the stream has been reached .
public static int readFully(final InputStream input, final byte[] array, final int offset, final int len)
            throws IOException {
        if (len < 0 || offset < 0 || len + offset > array.length || len + offset < 0) {
            throw new IndexOutOfBoundsException();
        }
        int count = 0, x = 0;
        while (count != len) {
            x = input.read(array, offset + count, len - count);
            if (x == -1) {
                break;
            }
            count += x;
        }
        return count;
    }
public static int readFully ( final InputStream input , final byte [ ] array , final int offset , final int len ) throws IOException { if ( len < 0 || offset < 0 || len + offset > array . length || len + offset < 0 ) { throw new IndexOutOfBoundsException ( ) ; } int count = 0 , x = 0 ; while ( count != len ) { x = input . read ( array , offset + count , len - count ) ; if ( x == - 1 ) { break ; } count += x ; } return count ; }
Reads as much from input as possible to fill the given array
 with the given amount of bytes.
Reads as much from input as possible to fill the given array with the given amount of bytes .