How to read from a text file

Common methods of the BufferedReader class

Constructors Throws Description
readLine() IOException Reads a line of text and returns it as a string
read() IOException Reads a single character and returns it as a int that represents the ASCII code for the character. -1 will be returned if EOF
skip(longValue) IOException Attempts to skip the specified number of characters, and returns an int value for the actual number of characters skipped.
close() IOException Close the input stream and flushes the buffer.

Example 1: Code that reads the records in a text file

// read the records of the file
String line = in.readLine();
while(line !=null)
{
System.out.println(line);
line = in.readLine();
}
// close the input stream
in.close();

More info can be found here: http://www.j2ee.me/javase/6/docs/api/java/io/BufferedReader.html