/** * Converts a byte array to a hexadecimal String. Each byte is presented by its two digit * hex-code; 0x0A -> "0a", 0x00 -> "00". No leading "0x" is included in the result. * * @param value the byte array to be converted * @return the hexadecimal string representation of the byte array */ public static String toHexString(byte[] value) { if (value == null) { return null; } StringBuffer buffer = new StringBuffer(2 * value.length); int single; for (int i = 0; i < value.length; i++) { single = value[i] & 0xFF; if (single < 0x10) { buffer.append('0'); } buffer.append(Integer.toString(single, 16)); } return buffer.toString(); }