code: public static byte[] toHex(int i) {
          StringBuilder buf = new StringBuilder(2);
          //don't forget the second hex digit
          if ((i & 0xff) < 0x10) {
              buf.append("0");
          }
          buf.append(Long.toString(i & 0xff, 16).toUpperCase());
          try {
              return buf.toString().getBytes("US-ASCII");
          }
          catch (Exception e) {
              logger.debug("Problem converting bytes to string - {}", e.getMessage());
          }
          return null;
      }
docs: Returns a <tt>byte[]</tt> containing the given
  byte as unsigned hexadecimal number digits.
  
  @param i the int to be converted into a hex string.
  
  @return the generated hexadecimal representation as <code>byte[]</code>.