Java Hex Calculate toHexString(byte[] arr)

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

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte[] arr) 

Method Source Code

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

public class Main {
    public static String toHexString(byte[] arr) {
        StringBuilder sb = new StringBuilder();
        boolean first = true;

        sb.append('[');
        for (byte b : arr) {
            if (first)
                first = false;//from   www.  j  ava  2 s.c  o m
            else
                sb.append(',');
            String s = Integer.toHexString(b & 0xFF);
            if (s.length() == 1)
                sb.append('0');
            sb.append(s);
        }
        sb.append(']');
        return sb.toString();
    }
}

Related

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