Java Byte to Hex byteToHex(byte b)

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

Description

Converts a byte to a hexadecimal string.

License

Apache License

Parameter

Parameter Description
b The byte value.

Return

The hexadecimal string.

Declaration

public static String byteToHex(byte b) 

Method Source Code

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

public class Main {
    /**/* ww  w  . ja  va  2 s  . c om*/
     * Converts a byte to a hexadecimal string.
     * 
     * @param b The byte value.
     * @return The hexadecimal string.
     */
    public static String byteToHex(byte b) {
        String str = "";
        if (((int) b & 0xff) < 0x10) {
            str += "0";
        }
        str += Long.toString((int) b & 0xff, 16);
        return str.toUpperCase();
    }
}

Related

  1. byteToHex(byte b)
  2. byteToHex(byte b)
  3. byteToHex(byte b)
  4. byteToHex(byte b)
  5. byteToHex(byte b)
  6. byteToHex(byte b)
  7. byteToHex(byte b, StringBuffer buf)
  8. byteToHex(byte bytevalue)
  9. ByteToHex(byte byyte)