Java Hex Calculate toHexString(byte bytes[])

Here you can find the source of toHexString(byte bytes[])

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte bytes[]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toHexString(byte bytes[]) {
        return toHexString(bytes, 0, bytes.length);
    }/*w w  w  .  j  a  va  2 s .  c o m*/

    public static String toHexString(byte bytes[], int start, int len) {
        if (len == 0)
            return "[]";
        StringBuffer sb = new StringBuffer();
        sb.append('[');
        sb.append(Integer.toHexString(bytes[start] & 0xff));
        for (int i = 1; i < len; i++)
            sb.append(',').append(Integer.toHexString(bytes[start + i] & 0xFF));

        sb.append("]");
        return sb.toString();
    }

    public static String toString(byte bytes[]) {
        return toString(bytes, 0, bytes.length);
    }

    public static String toString(byte bytes[], int start, int len) {
        if (len == 0)
            return "[]";
        StringBuffer sb = new StringBuffer();
        sb.append('[');
        sb.append(Integer.toString(bytes[start] & 0xff));
        for (int i = 1; i < len; i++)
            sb.append(',').append(Integer.toString(bytes[start + i] & 0xFF));

        sb.append("]");
        return sb.toString();
    }
}

Related

  1. toHexString(byte bytes[])
  2. toHexString(byte bytes[])
  3. toHexString(byte bytes[])
  4. toHexString(byte bytes[])
  5. toHexString(byte bytes[])
  6. toHexString(byte data[])
  7. toHexString(byte input[])
  8. toHexString(byte n)
  9. toHexString(byte value)