Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * Convert from int data into String hexadecimal (ex 255 => "0xFF") * * @param data data to convert into hexa * @return data converted into hexa */ public static String convertFromIntToHexa(byte data) { int dataTmp = data & 0xFF; /* Put character in uppercase */ String value = Integer.toHexString(dataTmp).toUpperCase(); /* Add 0 if length equal to 1 */ if (value.length() == 1) { value = "0" + value; } return value; } }