Refer to the Scanner API page and the Java IO tutorial.