Java Byte to Hex byteToHex(char val)

Here you can find the source of byteToHex(char val)

Description

Convert a byte to its hexadecimal value.

License

Open Source License

Parameter

Parameter Description
val a parameter

Declaration

private static String byteToHex(char val) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String HEX = "0123456789ABCDEF";

    /**/*from   w w w  .jav a  2 s .  c om*/
     * Convert a byte to its hexadecimal value.
     * 
     * @param val
     * @return
     */
    private static String byteToHex(char val) {
        int hi = (val & 0xF0) >> 4;
        int lo = (val & 0x0F);
        return "" + HEX.charAt(hi) + HEX.charAt(lo);
    }
}

Related

  1. byteToHex(byte bytevalue)
  2. ByteToHex(byte byyte)
  3. byteToHex(byte c)
  4. byteToHex(byte[] bytes)
  5. byteToHex(byte[] data)
  6. byteToHex(final byte b)
  7. byteToHex(final byte b)
  8. byteToHex(final byte b, StringBuilder buffer)
  9. byteToHex(final byte value)