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

StringBuilderappendHex(StringBuilder buf, int value, int width)
Converts the passed value into hexadecimal representation, and appends that representation to the buffer, left-zero-padded.
appendRepeat(buf, '0', width);
int offset = buf.length();
for (int ii = 1; ii <= width; ii++) {
    int nibble = value & 0xF;
    buf.setCharAt(offset - ii, NIBBLES[nibble]);
    value >>>= 4;
return buf;
...
voidappendHex(StringBuilder buff, int i)
append Hex
if (i >= 0 && i < 10) {
    buff.append((char) ('0' + i));
} else {
    buff.append((char) ('a' + (i - 10)));
voidappendHex(StringBuilder builder, int b)
append Hex
assertByte(b);
builder.append(DIGITS[b >> 4]);
builder.append(DIGITS[b & 0xf]);
voidappendHexByte(byte b, StringBuffer buf)
Append a byte in hexadecimal form, as two ASCII bytes, e.g.
char c = (char) ((b >> 4) & 0xF);
if (c > 9)
    c = (char) ((c - 10) + 'A');
else
    c = (char) (c + '0');
buf.append(c);
c = (char) (b & 0xF);
if (c > 9)
...
voidappendHexByte(final StringBuilder sb, final byte b)
append Hex Byte
final int v = Byte.toUnsignedInt(b);
sb.append(HEX_CHARS[v >>> 4]);
sb.append(HEX_CHARS[v & 15]);
voidappendHexBytes(StringBuilder builder, byte[] bytes)
append Hex Bytes
for (byte byteValue : bytes) {
    int intValue = byteValue & 0xFF;
    String hexCode = Integer.toString(intValue, 16);
    builder.append('%').append(hexCode);
voidappendHexDumpRowPrefix(StringBuilder dump, int row, int rowStartIndex)
append Hex Dump Row Prefix
dump.append(NEWLINE);
dump.append(Long.toHexString(rowStartIndex & 0xFFFFFFFFL | 0x100000000L));
dump.setCharAt(dump.length() - 9, '|');
dump.append('|');
voidappendHexEntity(final StringBuilder out, final char value)
Append the given char as a hexadecimal HTML entity.
out.append("&#x");
out.append(Integer.toHexString(value));
out.append(';');
voidappendHexEscape(StringBuilder out, int codePoint)
Appends the Unicode hex escape sequence for the given code point (backslash + 'u' + 4 hex digits) to the given StringBuilder.
if (Character.isSupplementaryCodePoint(codePoint)) {
    char[] surrogates = Character.toChars(codePoint);
    appendHexEscape(out, surrogates[0]);
    appendHexEscape(out, surrogates[1]);
} else {
    out.append("\\u").append(HEX_DIGITS[(codePoint >>> 12) & 0xF])
            .append(HEX_DIGITS[(codePoint >>> 8) & 0xF]).append(HEX_DIGITS[(codePoint >>> 4) & 0xF])
            .append(HEX_DIGITS[codePoint & 0xF]);
...
voidappendHexJavaScriptRepresentation(StringBuilder sb, char c)
Returns a javascript representation of the character in a hex escaped format.
sb.append("\\u");
String val = Integer.toHexString(c);
for (int j = val.length(); j < 4; j++) {
    sb.append('0');
sb.append(val);