See the API for Scanner (Java 2 Platform SE 5.0) (HINT: the first few paragraphs should address your problem)