Read lines of text from a file with the BufferedReader class
import java.io.BufferedReader; import java.io.FileReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new FileReader("filename.txt")); String line = null; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } }