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, int offset, int len, int max)
Creates a String containing the hexadecimal representation of the given bytes.
if (bytes == null)
    return "[null]";
int count = max > -1 && max < len ? max : len;
StringBuffer s = new StringBuffer();
for (int i = 0; i < count; i++) {
    String b = Integer.toHexString(bytes[offset + i] & 0xFF).toUpperCase();
    if (b.length() == 1)
        s.append('0');
...
StringtoHexString(byte[] bytes, String separator, boolean upperCase)
to Hex String
StringBuilder hexString = new StringBuilder();
for (byte b : bytes) {
    String str = Integer.toHexString(0xFF & b); 
    if (upperCase) {
        str = str.toUpperCase();
    if (str.length() == 1) {
        hexString.append("0");
...
StringtoHexString(byte[] coded)
to Hex String
if (coded == null) {
    return "";
return toHexString(coded, 0, coded.length);
StringtoHexString(byte[] color)
to Hex String
char[] hexChars = new char[color.length * 2];
int x;
for (int i = 0; i < color.length; i++) {
    x = color[i] & 0xFF;
    hexChars[i * 2] = HEX[x >>> 4];
    hexChars[i * 2 + 1] = HEX[x & 0x0F];
return new String(hexChars);
...
StringtoHexString(byte[] content, int len)
to Hex String
if (content == null || content.length == 0) {
    return "";
if (len > content.length) {
    len = content.length;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i++) {
...
StringtoHexString(byte[] data)
to Hex String
return toHexString(toIntArray(data));
StringtoHexString(byte[] data)
to Hex String
return toHexString(data, 0, data.length);
StringtoHexString(byte[] data)
Returns the specified data as hex sequence
final int n = data.length;
final StringBuilder hex = new StringBuilder();
for (int i = 0; i < n; i++) {
    final byte b = data[i];
    hex.append(String.format("%02x", b & 0xff));
return hex.toString();
StringtoHexString(byte[] data)
to Hex String
return toHexString(data, " ");
StringtoHexString(byte[] data)
Turn a bytearray into a printable form, representing each byte in hex.
StringBuffer sb = new StringBuffer(data.length * 2);
for (int i = 0; i < data.length; ++i) {
    sb.append(Integer.toHexString((data[i] >> 4) & 15));
    sb.append(Integer.toHexString(data[i] & 15));
return sb.toString();