public static int read2Bytes(final String name, final InputStream in, final String exception, final ByteOrder byteOrder) throws IOException {
        final int byte0 = in.read();
        final int byte1 = in.read();
        if ((byte0 | byte1) < 0) {
            throw new IOException(exception);
        }
        final int result;
        if (byteOrder == ByteOrder.BIG_ENDIAN) {
            result = byte0 << 8 | byte1;
        } else {
            result = byte1 << 8 | byte0;
        }
        return result;
    }
Convert a quad into a byte array.

@param quad quad
@return a byte array
src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java