Almost the same code can be used to read integers from a file.
The only difference is in the creation of the Scanner.
After that, the code is the same.