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

StringtoHexString(byte[] bytes)
to Hex String
StringBuilder hexString = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
    hexString.append(enoughZero(Integer.toHexString(bytes[i] & 0xff), 2));
return hexString.toString();
StringtoHexString(byte[] bytes)
Converts a byte array to a string of hexadecimal characters.
if (bytes == null) {
    return "";
final int len = bytes.length;
if (len == 0) {
    return "";
char[] hexChars = new char[len * 2];
...
StringtoHexString(byte[] bytes)
Convert a set of bytes into a hexadecimal string.
StringBuilder sb = new StringBuilder();
for (byte aByte : bytes) {
    sb.append(Integer.toHexString(0xff & aByte));
return sb.toString();
StringtoHexString(byte[] bytes)
to Hex String
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
    sb.append(HEX_CHARS[bytes[i] >> 4 & 0x0f]);
    sb.append(HEX_CHARS[bytes[i] & 0x0f]);
return sb.toString();
StringtoHexString(byte[] bytes)
to Hex String
StringBuilder sb = new StringBuilder(bytes.length * 2);
int i;
for (i = 0; i < bytes.length; i++) {
    if ((bytes[i] & 0xff) < 0x10)
        sb.append(STR_0);
    sb.append(Long.toString(bytes[i] & 0xff, 16));
return sb.toString();
...
StringtoHexString(byte[] bytes)
converts all bytes into a hex string of length bytes.length * 2
return toHexString(bytes, 0, bytes.length, 0);
StringtoHexString(byte[] bytes)
to Hex String
String string = "";
for (int i = 0; i < bytes.length; i++) {
    if ((0xff & bytes[i]) < 0x10) {
        string += "0" + Integer.toHexString((0xFF & bytes[i]));
    } else {
        string += Integer.toHexString(0xFF & bytes[i]);
return string;
StringtoHexString(byte[] bytes)
Returns a string representings the hexadecimal values of the bytes.
if (bytes == null || bytes.length == 0) {
    return "";
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
    if (((int) bytes[i] & 0xff) < 0x10) {
        buffer.append("0");
    buffer.append(Long.toString((int) bytes[i] & 0xff, 16));
return buffer.toString();
StringtoHexString(byte[] bytes)
to Hex String
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
    String temp = Integer.toHexString(0xFF & bytes[i]);
    if (temp.length() < 2) {
        sb.append("0");
    sb.append(temp);
return sb.toString();
StringtoHexString(byte[] bytes)
to Hex String
StringBuilder sb = new StringBuilder(bytes.length * 3);
for (int b : bytes) {
    b &= 0xff;
    sb.append(HEX_DIGITS[b >> 4]);
    sb.append(HEX_DIGITS[b & 15]);
    sb.append(' ');
return sb.toString();
...