How big are the values? Java 6 has a Scanner class that can read anything from int (32-bit), long (64-bit) to BigInteger (an arbitrary large integer).
There is a scanner for Java 5 or 4, but BigInteger support is not supported. You must read line by line (using the readLine of the Scanner class) and create a BigInteger object from line.
source share