我有长度为80位的十六进制字符串,如“12345ABCDEF78E9CD741”,需要转换为二进制字符串。
我尝试了以下代码 String Skey =“12345ABCDEF78E9CD741”; int i = Integer.parseInt(Skey,16); String bin = Integer.toBinaryString(i);
但整数不能保持80位。那么如何在java中完成。
答案 0 :(得分:1)
Parse it to a BigInteger
和convert that to binary
BigInteger bigint = new BigInteger("12345ABCDEF78E9CD741", 16);
System.out.println(bigint.toString(2));
10010001101000101101010111100110111101111011110001110100111001101011101000001