Java Byte Array to Hex bytes2Hex(byte bt)

Here you can find the source of bytes2Hex(byte bt)

Description

bytes Hex

License

LGPL

Declaration

public static String bytes2Hex(byte bt) 

Method Source Code

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

public class Main {
    public static String bytes2Hex(byte bt) {
        return ("" + "0123456789ABCDEF".charAt(0xf & bt >> 4) + "0123456789ABCDEF".charAt(bt & 0xf));
    }//from  w  w  w . j  a va 2 s  .  c o m

    public static String bytes2Hex(byte[] bts) {
        String des = "";
        String tmp = null;
        for (int i = 0; i < bts.length; i++) {
            tmp = Integer.toHexString(bts[i] & 0xFF);
            if (tmp.length() == 1) {
                des += "0";
            }
            des += tmp;
        }
        return des;
    }
}

Related

  1. bufferToHex(byte bytes[])
  2. bufferToHexString(byte[] buffer)
  3. bufferToHexString(byte[] data, int start, int length)
  4. bytes2Hex(byte... values)
  5. bytes2Hex(byte[] abValue)
  6. bytes2Hex(byte[] b)
  7. bytes2Hex(byte[] b)