I keep getting number format expectations, even though I\'m trimming the strings and they don\'t contain non numerical characters bizarrely it works for some numbers and not
The largest number parseable as an int is 2147483647 (231-1), and the largest long is 9223372036854775807 (263-1), only about twice as long.
int
2147483647
long
9223372036854775807
To parse arbitrarily long numbers, use:
import java.math.BigInteger; BigInteger number = new BigInteger(str);