/* PURPOSE: To read from a file... */ import java.io.IOException; import java.io.FileNotFoundException; import java.io.BufferedReader; import java.io.FileReader; public class ReadingTester { public static void main(String[] args) throws IOException { //1-OPEN FILE //The file needs to be in the same folder as your java file. //Change the file name as you need. String fileName = "testme.txt"; BufferedReader in = new BufferedReader(new FileReader(fileName)); //2-READ DATA //Data is read one line at a time. String line = in.readLine(); while(line != null) { //DO WHAT YOU WANT WITH THE LINE //For example, we can output the line to screen. System.out.println(line); //UPDATE line to NEXT LINE line = in.readLine(); } //3-CLOSE THE FILE in.close(); } }