I have a method:
public BigInteger method(String param){
try{
return new BigInteger(param);
}catch(NumberFormatException e){
LOG.error(e, e);
}
}
I want to check if I can create a BigInteger
from those String param
without generating NumberFormatException
.
Is there any way do it this way?
Basically you have 2 possible approaches:
You check if the String does only contain numbers, and not more than you could have in a Bigint
cast in a try{}catch()
and catch everything... this is not very performant and more a lazy method of doing it!
Here you can probably find some inspiration :)