Java Byte Array to Hex bytes2Hex(byte... values)

Here you can find the source of bytes2Hex(byte... values)

Description

bytes Hex

License

Apache License

Declaration

public static String bytes2Hex(byte... values) 

Method Source Code

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

public class Main {

    public static String bytes2Hex(byte... values) {
        StringBuffer bf = new StringBuffer();
        for (byte b : values) {
            String str = byte2Hex(b, false);
            bf.append(str);//from  w  w  w.j a  va  2s .  com
        }
        return bf.toString();
    }

    public static String byte2Hex(byte value, boolean showx) {
        int value0 = (value & 0xff);
        String v = Integer.toHexString(value0);
        if (v.length() % 2 != 0) {
            v = "0" + v;
        }
        return showx ? ("0x" + v) : v;
    }

    public static String byte2Hex(byte value) {
        return byte2Hex(value, true);
    }
}

Related

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