Here you can find the source of toHex(int num)
public static String toHex(int num)
//package com.java2s; public class Main { public static String toHex(int num) { num = num & 0xff;/* ww w . j ava 2s .c om*/ final String hex = Integer.toHexString(num); return hex.length() == 1 ? "0" + hex : hex; } }