public static byte[] toBytes(long val) {
        byte[] b = new byte[8];
        for (int i = 7; i > 0; i--) {
            b[i] = (byte) val;
            val >>>= 8;
        }
        b[0] = (byte) val;
        return b;
    }
Convert a long value to a byte array using big-endian.

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