Android Hex String Create hexToBt64(String hex)

Here you can find the source of hexToBt64(String hex)

Description

hex To Bt

Declaration

private static String hexToBt64(String hex) 

Method Source Code

//package com.java2s;

public class Main {
    private static String hexToBt64(String hex) {
        String binary = "";
        for (int i = 0; i < 16; i++) {
            binary += hexToBt4(hex.substring(i, i + 1));
        }//from w  ww. j  a  v  a  2s . com
        return binary;
    }

    private static String hexToBt4(String hex) {
        String binary = "";
        if (hex.equalsIgnoreCase("0")) {
            binary = "0000";
        } else if (hex.equalsIgnoreCase("1")) {
            binary = "0001";
        }
        if (hex.equalsIgnoreCase("2")) {
            binary = "0010";
        }
        if (hex.equalsIgnoreCase("3")) {
            binary = "0011";
        }
        if (hex.equalsIgnoreCase("4")) {
            binary = "0100";
        }
        if (hex.equalsIgnoreCase("5")) {
            binary = "0101";
        }
        if (hex.equalsIgnoreCase("6")) {
            binary = "0110";
        }
        if (hex.equalsIgnoreCase("7")) {
            binary = "0111";
        }
        if (hex.equalsIgnoreCase("8")) {
            binary = "1000";
        }
        if (hex.equalsIgnoreCase("9")) {
            binary = "1001";
        }
        if (hex.equalsIgnoreCase("A")) {
            binary = "1010";
        }
        if (hex.equalsIgnoreCase("B")) {
            binary = "1011";
        }
        if (hex.equalsIgnoreCase("C")) {
            binary = "1100";
        }
        if (hex.equalsIgnoreCase("D")) {
            binary = "1101";
        }
        if (hex.equalsIgnoreCase("E")) {
            binary = "1110";
        }
        if (hex.equalsIgnoreCase("F")) {
            binary = "1111";
        }
        return binary;
    }
}

Related

  1. hexStringToBytes(String hexString)
  2. appendHex(StringBuffer stringbuffer, byte byte0)
  3. toHexString(char achar0)
  4. decodeHexStr(final String str)
  5. hexDigest(String input)
  6. hexToBytes(String hex)
  7. convertToHex(byte[] data)
  8. convertToHex(byte[] data)
  9. byte2HexStr(byte[] b, int length)