Take a look at this for help on how Scanners work. Scanner (Java 2 Platform SE 5.0)