Java Hex Calculate toHexString(byte[] b)

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

Description

to Hex String

License

Apache License

Declaration


public static String toHexString(byte[] b) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String toHexString(byte[] b) {
        char[] hexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
        StringBuilder sb = new StringBuilder(b.length * 2);
        for (int i = 0; i < b.length; i++) {
            sb.append(hexChar[(b[i] & 0xf0) >>> 4]);
            sb.append(hexChar[b[i] & 0x0f]);
        }/*from   ww  w .ja v  a  2 s.c  o  m*/
        return sb.toString();
    }
}

Related

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