Read the API doc for the Scanner class. It has several methods for reading different types of data.
Java Platform SE 6