Java examples for File Path IO:Text File
Read text file through a buffered character stream
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { public static void main(String[] arguments) { try (FileReader file = new FileReader("SourceReader.java"); BufferedReader buff = new BufferedReader(file)) { boolean eof = false; while (!eof) { String line = buff.readLine(); if (line == null) { eof = true;/*from ww w . j ava 2s . c o m*/ } else { System.out.println(line); } } buff.close(); } catch (IOException e) { System.out.println("Error -- " + e.toString()); } } }