The most naive way would be to iterate over the String and make sure all the elements are valid digits for the given radix. This is about as efficient...
Convert boolean to int in Java