public static byte[] getBytes(final RandomAccessFile raf, final long pos, final int length, final String exception) throws IOException {
        if (length < 0) {
            throw new IOException(String.format("%s, invalid length: %d", exception, length));
        }
        Allocator.checkByteArray(length);
        return RandomAccessFiles.read(raf, pos, length);

    }
Copies the start of the specified array into a new array.

@param original the array from which a range is to be copied.
@param count    the amount of bytes to copy.
@return a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length.
src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java