Here you can find the source of intToHexString(int value)
Parameter | Description |
---|---|
value | The integer value to be converted |
public static String intToHexString(int value)
//package com.java2s; public class Main { /**//from w ww. ja v a 2s. c om * A static array of the hexadecimal digits where their position represents their ordinal value */ private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Convert an integer value into a hexadecimal representation that is long enough to contain the significant digits. * * @param value * The integer value to be converted * @return The string representation of the value as a hexadecimal representation */ public static String intToHexString(int value) { StringBuffer buffer = new StringBuffer(); int temp = value; do { int index = temp % 16; buffer.insert(0, HEX_DIGITS[index]); temp = temp / 16; } while (temp > 0); return buffer.toString(); } }