Here you can find the source of toHexString(int b)
Parameter | Description |
---|---|
b | byte to convert to hex string |
public static String toHexString(int b)
//package com.java2s; /*//from ww w .j a v a 2 s . c om * BJAF - Beetle J2EE Application Framework * ???J2EE??????????? * ??????2003-2015 ??? (www.beetlesoft.net) * * ?????????????????? *<http://www.apache.org/licenses/LICENSE-2.0> *???????????????????????? * * ??????????????????????????????? * ??? <yuhaodong@gmail.com/>. */ public class Main { private static char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Returns a hex string representation of a 8 bit integer. Very fast. * Returned hex values are in uppercase. * * @param b * byte to convert to hex string * * @return hex value */ public static String toHexString(int b) { char[] digits = new char[2]; b = b & 255; digits[0] = hexDigits[b / 0x10]; digits[1] = hexDigits[b % 0x10]; return new String(digits); } }