Java Utililty Methods Hex String Create

List of utility methods to do Hex String Create

Description

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

Method

voidappendHexNumber(StringBuffer target, byte b)
append Hex Number
int lo = b & 0xf;
int hi = (b >> 4) & 0xf;
target.append(HEX[hi]);
target.append(HEX[lo]);
voidappendHexPair(byte b, StringBuffer sb)
append Hex Pair
char c0 = hexDigits[(b & 0xf0) >> 4];
char c1 = hexDigits[b & 0x0f];
sb.append(c0);
sb.append(c1);
voidappendHexStream(StringBuilder sb, byte[] bytes, String delimiter, boolean prefixEachValue, boolean upperCase)
Same as #toHexStream(byte[],String,boolean,boolean) , but appends to an existing StringBuilder.
sb.ensureCapacity(bytes.length * (prefixEachValue ? 4 : 2)
        + (bytes.length - 1) * (delimiter == null ? 0 : delimiter.length()));
for (int i = 0; i < bytes.length; i++) {
    if (prefixEachValue)
        sb.append("0x");
    char c1 = Character.forDigit((bytes[i] & 0xF0) >> 4, 16);
    char c2 = Character.forDigit((bytes[i] & 0x0F), 16);
    sb.append(upperCase ? Character.toUpperCase(c1) : c1);
...
voidappendHexString(StringBuffer buffer, byte data)
Append hex string from byte to StringBuffer
int positive = data < 0 ? ~data : data;
buffer.append(HEX_DIGITS[positive >> 4]);
buffer.append(HEX_DIGITS[positive & 0xf]);
voidappendHexString(StringBuilder buffer, byte[] bytes)
Appends a byte array to a StringBuilder with each byte in a "Big Endian" hexidecimal format.
assertNotNull(buffer);
if (bytes == null) {
    return; 
appendHexString(buffer, bytes, 0, bytes.length);
voidappendHexString(StringBuilder builder, int value)
append Hex String
String hex = Integer.toHexString(value);
if (hex.length() == 1) {
    builder.append("0");
builder.append(hex);
voidappendHexValue(final StringBuffer sb, final byte data)
Convert a byte into hex value and add to buffer.
sb.append(nibbleToHex((byte) (data >> 4)));
sb.append(nibbleToHex(data));
voidappendHexValue(StringBuffer buffer, byte b)
Helper method that converts a single byte to a hex string representation.
int[] digits = { (b >>> 4) & 0x0F, b & 0x0F };
for (int d = 0; d < digits.length; ++d) {
    int increment = (int) ((digits[d] < 10) ? '0' : ('a' - 10));
    buffer.append((char) (digits[d] + increment));