Java Hex to Byte convertHexDigit(byte b)

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

Description

Convert a byte character value to hexadecimal digit value.

License

Open Source License

Parameter

Parameter Description
b the character value byte

Declaration

private static byte convertHexDigit(byte b) 

Method Source Code

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

public class Main {
    /***//from w  w w .j a  va 2 s.c o  m
     * Convert a byte character value to hexadecimal digit value.
     *
     * @param b the character value byte
     */
    private static byte convertHexDigit(byte b) {
        if ((b >= '0') && (b <= '9'))
            return (byte) (b - '0');
        if ((b >= 'a') && (b <= 'f'))
            return (byte) (b - 'a' + 10);
        if ((b >= 'A') && (b <= 'F'))
            return (byte) (b - 'A' + 10);
        throw new IllegalArgumentException("requestUtil.convertHexDigit.notHex" + Character.valueOf((char) b));
    }
}

Related

  1. convertHexCharacterToHalfByte(char character)
  2. convertHexDigit(byte b)
  3. convertHexDigit(byte b)
  4. convertHexDigit(byte b)
  5. convertHexDigit(byte c)