java/scala 16进制转10进制代码,解决Exception in thread “main“ java.lang.NumberFormatException: For input strin
16进制转10进制的3种方法, Integer.parseInt(xxx,16), Long.parseLong(xxx,16), 并解决Exception in thread "main" java.lang.NumberFormatException: For input string.如果16进制数过大, 转10进制会报错, 则需要使用BigInteger来解决.
·
方式1,使用Integer
Integer.parseInt(str, 16)
如:
int baiduId = Integer.parseInt(tBaiduQid, 16);
方式2, 使用Long
Long.parseLong(tBaiduQid, 16)
如:
long baiduId = Long.parseLong(tBaiduQid, 16);
如果16进制数过大, 转10进制会报错, 则需要使用BigInteger来解决.
Exception in thread "main" java.lang.NumberFormatException: For input string: "9b328cf65ab40260"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:583)
at com.baidu.anti.ShoubaiHack.evaluate(ShoubaiHack.java:140)
at com.baidu.anti.ShoubaiHack.main(ShoubaiHack.java:26)
方式3, 使用BigInteger
import java.math.BigInteger;
BigInteger bigInteger = new BigInteger(tBaiduQid, 16);
更多推荐
所有评论(0)