Java Byte to Hex bytes2hex(byte[] bts)

Here you can find the source of bytes2hex(byte[] bts)

Description

byteshex

License

Apache License

Declaration

public static String bytes2hex(byte[] bts) 

Method Source Code

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

public class Main {
    public static String bytes2hex(byte[] bts) {
        char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
        int j = bts.length;
        char str[] = new char[j * 2];
        int k = 0;
        for (int i = 0; i < j; i++) {
            byte byte0 = bts[i];
            str[k++] = hexDigits[byte0 >>> 4 & 0xf];
            str[k++] = hexDigits[byte0 & 0xf];
        }/*  w  w w  .  j a  v  a2s.  c  om*/
        return new String(str);
    }
}

Related

  1. bytes2hex(byte[] binput)
  2. bytes2hex(byte[] bytes)
  3. bytes2hex(byte[] bytes)
  4. bytes2hex(byte[] bytes)
  5. Bytes2HexString(byte[] b)