Java Byte Array to Hex byteToHex(byte data)

Here you can find the source of byteToHex(byte data)

Description

byte To Hex

License

Open Source License

Declaration

public static String byteToHex(byte data) 

Method Source Code

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

public class Main {
    public static String byteToHex(byte data) {
        StringBuffer buf = new StringBuffer();
        buf.append(toHexChar((data >>> 4) & 0x0F));
        buf.append(toHexChar(data & 0x0F));
        return buf.toString();
    }//from  w w  w.ja v a 2  s .c  o m

    public static char toHexChar(int i) {
        if ((0 <= i) && (i <= 9)) {
            return (char) ('0' + i);
        } else {
            return (char) ('a' + (i - 10));
        }
    }
}

Related

  1. byteToHex(byte b)
  2. byteToHex(byte b)
  3. byteToHex(byte b[])
  4. byteToHex(byte b[])
  5. byteToHex(byte bytes[])
  6. byteToHex(byte[] array)
  7. byteToHex(byte[] array, String separator)
  8. byteToHex(byte[] b, int size)
  9. byteToHex(byte[] base)