Convert hexadecimal string (hex) to a binary string

后端 未结 7 2017
孤独总比滥情好
孤独总比滥情好 2020-11-30 07:31

I found the following way hex to binary conversion:

String binAddr = Integer.toBinaryString(Integer.parseInt(hexAddr, 16)); 

While this app

7条回答
  •  粉色の甜心
    2020-11-30 08:19

    BigInteger.toString(radix) will do what you want. Just pass in a radix of 2.

    static String hexToBin(String s) {
      return new BigInteger(s, 16).toString(2);
    }
    

提交回复
热议问题