Java Char to Byte charToByte(char aChar)

Here you can find the source of charToByte(char aChar)

Description

char To Byte

License

Open Source License

Declaration

public static byte charToByte(char aChar) 

Method Source Code

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

public class Main {
    public static byte charToByte(char aChar) {
        byte ref;
        if (aChar >= '0' && aChar <= '9') {
            ref = (byte) '0';
        } else if (aChar >= 'a' && aChar <= 'f') {
            ref = (byte) 'a' - 10;
        } else {/*from w w  w . j a va2s  . co m*/
            throw new IllegalArgumentException("The char '" + aChar + "' is a not valid hex value");
        }

        return (byte) (aChar - ref);
    }
}

Related

  1. char2bb(char[] c)
  2. char2Byte(char c)
  3. char2Byte(char ch)
  4. char2byte(char ch)
  5. charToByte(char c)
  6. charToByte(char c)
  7. charToByte(char c)
  8. charToByte(char c)