Here you can find the source of toHexString(int iValue)
static public String toHexString(int iValue)
//package com.java2s; //License from project: Apache License public class Main { static public String toHexString(byte[] bytes) { StringBuffer strBuffer = new StringBuffer(50); for (int i = 0; i < bytes.length; i++) strBuffer.append(toHexString(bytes[i])); return strBuffer.toString(); }/*from w ww .j a v a 2 s . c om*/ static public String toHexString(int iValue) { String str = Integer.toHexString(iValue); if (str.length() == 1) return "0" + str; /** * if iValue >= 128, it will return ffffff80, we need to cut off first 6 digits * only get last two digits */ else if (str.length() == 8) return str.substring(6, 8); return str; } }