Java BufferedReader read text file line by line
import java.io.BufferedReader; import java.io.FileReader; public class Main { public static void main(String[] args) throws Exception{ String srcFile = "Main.java"; BufferedReader br = new BufferedReader(new FileReader(srcFile)); String text = null;/*from w w w.jav a 2 s . c o m*/ while ((text = br.readLine()) != null) { System.out.println(text); } br.close(); } }