code: public static byte[] longToBytes(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;
    }
docs: Convert long value to byte array.
  
  @param val the long value
  @return the byte array of this value