Here you can find the source of toHexString(int number, int digit)
private static String toHexString(int number, int digit)
//package com.java2s; //The MIT License public class Main { private static final String HEX_LETTER = "0123456789ABCDEF"; private static String toHexString(int number, int digit) { String result = ""; while (digit-- > 0) { int n = number % 16; number /= 16;// w w w.j av a 2 s. c o m result = HEX_LETTER.substring(n, n + 1) + result; } return result; } }