Search code examples
javaandroidbigintegerstring-parsing

Create BigInt with a String encoded to base 16


I am trying to parse a String like this:

f2cff0a43553b2e07b6ae3264bc085a

into a BigInt however when using the String constructor for BigInt I obviously get a Number format exception:

BigInteger bi = new BigInteger("f2cff0a43553b2e07b6ae3264bc085a");

Any ideas how I can do this?


Solution

  • Use the radix parameter:

    BigInteger bi = new BigInteger("f2cff0a43553b2e07b6ae3264bc085a", 16);