Java Utililty Methods Array to Hex String

List of utility methods to do Array to Hex String

Description

The list of methods to do Array to Hex String are organized into topic(s).

Method

StringarrayToHexString(byte[] array)
Helper method to convert a byte[] array (such as a MsgId) to a hex string
return arrayToHexString(array, 0, array.length);
Stringarraytohexstring(byte[] bytes)
arraytohexstring
StringBuilder string = new StringBuilder();
for (byte b : bytes) {
    String hexString = Integer.toHexString(0x00FF & b);
    string.append(hexString.length() == 1 ? "0" + hexString : hexString);
return string.toString();
StringarrayToHexString(final byte[] byteArray)
Convert a byte array into hex sequence like [#01 #02 #03]
final StringBuilder result = new StringBuilder();
result.append('[');
boolean space = false;
for (final byte b : byteArray) {
    if (space) {
        result.append(' ');
    } else {
        space = true;
...