Java Utililty Methods Hex Calculate

List of utility methods to do Hex Calculate

Description

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

Method

StringtoHex(byte[] bytes)
to Hex
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte aByte : bytes) {
    int b = aByte & 0xFF;
    if (b < 0x10) {
        sb.append('0');
    sb.append(Integer.toHexString(b));
return sb.toString();
StringtoHex(byte[] bytes)
Byte array to Hex info
if (bytes == null || bytes.length == 0)
    return "";
String hex = "";
for (int i = 0; i < bytes.length; i++) {
    int num = 0xFF & bytes[i];
    int div = num / 16;
    int rem = num % 16;
    if (div > 9) {
...
StringtoHex(byte[] bytes, int maxlen)
Converts a byte array to a (Oracle & SQL Server) hex string.
int len = bytes.length;
if (maxlen > 0) {
    len = Math.min(bytes.length, maxlen);
StringBuffer result = new StringBuffer(len * 2);
for (int i = 0; i < len; ++i) {
    byte b = bytes[i];
    result.append(s_digits[(b & 0xf0) >>> 4]);
...
StringtoHex(byte[] data)
Return the passed in byte array as a hex string.
return toHex(data, data.length);
StringtoHex(byte[] data)
to Hex
char[] str = new char[data.length + data.length];
for (int i = data.length - 1, strIndex = str.length - 1; i >= 0; i--) {
    byte byte4i = data[i];
    str[strIndex--] = hexDigits[byte4i & 0xF];
    str[strIndex--] = hexDigits[byte4i >>> 4 & 0xF];
return new String(str);
StringtoHex(byte[] data)
to Hex
int len = data.length;
byte[] out = new byte[len << 1];
byte cur;
for (int i = 0; i < len; i++) {
    cur = data[i];
    out[(i << 1) + 1] = TO_HEX[cur & 0xF];
    out[i << 1] = TO_HEX[(cur >> 4) & 0xF];
return new String(out);
StringtoHex(byte[] data)
Convert data to a string of hex-digits.
StringBuilder sb = new StringBuilder();
for (byte b : data) {
    sb.append(nibbleToHex(b >>> 4));
    sb.append(nibbleToHex(b));
return sb.toString();
StringtoHex(byte[] data)
Return a hex representation of the byte array
if ((data == null) || (data.length == 0)) {
    return null;
StringBuffer result = new StringBuffer();
for (int i = 0; i < data.length; i++) {
    int low = (int) (data[i] & 0x0F);
    int high = (int) (data[i] & 0xF0);
    result.append(Integer.toHexString(high).substring(0, 1));
...
StringtoHex(byte[] data)
to Hex
if ((data == null) || (data.length == 0)) {
    return null;
char[] chars = new char[2 * data.length];
for (int i = 0; i < data.length; ++i) {
    chars[2 * i] = HEX_CHARS[(data[i] & 0xF0) >>> 4];
    chars[2 * i + 1] = HEX_CHARS[data[i] & 0x0F];
return new String(chars);
StringtoHex(byte[] data)
to Hex
return toHex(data, false);