I would suggest you read about the scanner class and become familiar with the methods available and their usage. Reading that page will answer your question and perhaps teach you even more useful...