Java Char Convert To charToNum(char c)

Here you can find the source of charToNum(char c)

Description

char To Num

License

Open Source License

Declaration

private static byte charToNum(char c) 

Method Source Code

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

public class Main {
    private static byte charToNum(char c) {
        switch (c) {
        case '0':
            return 0x0;
        case '1':
            return 0x1;
        case '2':
            return 0x2;
        case '3':
            return 0x3;
        case '4':
            return 0x4;
        case '5':
            return 0x5;
        case '6':
            return 0x6;
        case '7':
            return 0x7;
        case '8':
            return 0x8;
        case '9':
            return 0x9;
        case 'a':
        case 'A':
            return 0xA;
        case 'b':
        case 'B':
            return 0xB;
        case 'c':
        case 'C':
            return 0xC;
        case 'd':
        case 'D':
            return 0xD;
        case 'e':
        case 'E':
            return 0xE;
        case 'f':
        case 'F':
            return 0xF;
        default:/*from  w  ww  . jav  a  2  s.  co  m*/
            throw new NumberFormatException(String.format("%c is not a valid hex digit", c));
        }
    }
}

Related

  1. charToEscape(char ch)
  2. charToHTML(char ch, boolean xml)
  3. charToLong(final char value)
  4. charToLowerCase(char c)
  5. charToNCRef(int c)
  6. charToNybble(char c)
  7. charToOctet(char c)
  8. charToUpperOrLower(String string, int pos, boolean upper)
  9. convertChar(char c)