public static byte[] toBytes(int val) {
        byte[] b = new byte[4];
        for (int i = 3; i > 0; i--) {
            b[i] = (byte) val;
            val >>>= 8;
        }
        b[0] = (byte) val;
        return b;
    }
Convert an int value to a byte array. Big-endian. Same as what DataOutputStream.writeInt does.

@param val value
@return the byte array
stroom-bytebuffer/src/main/java/stroom/bytebuffer/hbase/Bytes.java