code: 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;
    }
docs: Convert an int value to a byte array.
  @param val value
  @return the byte array