Java Binary Encode toBinFromHexChar(final char hex)

Here you can find the source of toBinFromHexChar(final char hex)

Description

to Bin From Hex Char

License

Open Source License

Declaration

public static String toBinFromHexChar(final char hex) 

Method Source Code

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

public class Main {
    public static String toBinFromHexChar(final char hex) {
        switch (hex) {
        case '0':
            return ("0000");
        case '1':
            return ("0001");
        case '2':
            return ("0010");
        case '3':
            return ("0011");
        case '4':
            return ("0100");
        case '5':
            return ("0101");
        case '6':
            return ("0110");
        case '7':
            return ("0111");
        case '8':
            return ("1000");
        case '9':
            return ("1001");
        case 'a':
        case 'A':
            return ("1010");
        case 'b':
        case 'B':
            return ("1011");
        case 'c':
        case 'C':
            return ("1100");
        case 'd':
        case 'D':
            return ("1101");
        case 'e':
        case 'E':
            return ("1110");
        case 'f':
        case 'F':
            return ("1111");
        default:/*from w  w  w . j av  a2s .  c  om*/
            throw new IllegalArgumentException(
                    "The input character \'" + hex + "\'is not a valid hexadecimal character.");
        }
    }
}

Related

  1. toBinaryString(long value, int bitLegnth)
  2. toBinaryStringAddress(long address)
  3. toBinaryText(StringBuffer buf)
  4. toBinFromByte(final byte b)
  5. toBinFromHex(final String hexSymbols)
  6. toBinFromOct(final String octSymbols)
  7. toBinFromOctChar(final char oct)
  8. toBinString(byte b)
  9. toBinString(byte value)