aliocrlib/src/main/java/com/lib/aliocr/utils/io/IOUtils.java
/**
     * Read the requested number of bytes or fail if there are not enough left.
     * <p/>
     * This allows for the possibility that {@link InputStream#read(byte[], int, int)} may
     * not read as many bytes as requested (most likely because of reaching EOF).
     *
     * @param input  where to read input from
     * @param buffer destination
     * @param offset inital offset into buffer
     * @param length length to read, must be >= 0
     * @throws IOException              if there is a problem reading the file
     * @throws IllegalArgumentException if length is negative
     * @throws EOFException             if the number of bytes read was incorrect
     * @since 2.2
     */
Read the requested number of bytes or fail if there are not enough left.

This allows for the possibility that  InputStream#read(byte[], int, int) may
not read as many bytes as requested (most likely because of reaching EOF).


Read the requested number of bytes or fail if there are not enough left . This allows for the possibility that InputStream#read ( byte [] int int ) may not read as many bytes as requested ( most likely because of reaching EOF ) .
@SuppressWarnings("SameParameterValue")
    public static void readFully(InputStream input, byte[] buffer, int offset, int length) throws IOException {
        int actual = read(input, buffer, offset, length);
        if (actual != length) {
            throw new EOFException("Length to read: " + length + " actual: " + actual);
        }
    }
@ SuppressWarnings ( "SameParameterValue" ) public static void readFully ( InputStream input , byte [ ] buffer , int offset , int length ) throws IOException { int actual = read ( input , buffer , offset , length ) ; if ( actual != length ) { throw new EOFException ( "Length to read: " + length + " actual: " + actual ) ; } }
Read the requested number of bytes or fail if there are not enough left.
Read the requested number of bytes or fail if there are not enough left .