Here you can find the source of intToHexString(int i)
public static String intToHexString(int i)
//package com.java2s; // Licensed under the Academic Free License version 3.0 public class Main { /**//from w ww .j av a 2s .c o m * @return a 32-bit integer to a hex string, but guarantee that * the string is eight chars long by padding with leading zeros */ public static String intToHexString(int i) { return intToHexString(i, 8); } /** * @return a 32-bit integer to a hex string, but guarantee that * the string is <code>minChars</code> chars long by padding with leading zeros */ public static String intToHexString(int i, int minChars) { if ((minChars < 1) || (minChars > 8)) minChars = 8; String s = Integer.toHexString(i); while (s.length() < minChars) s = "0" + s; return s; } /** * Return hex string of bytes. */ public static String toHexString(byte[] b) { StringBuffer s = new StringBuffer(); for (int i = 0; i < b.length; ++i) s.append(byteToHexString(b[i])); return s.toString(); } /** * @return byte to two character hex string. */ public static String byteToHexString(int b) { String s = Integer.toHexString(b & 0xFF); if (s.length() == 1) return "0" + s; else return s; } }