Java Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import java.io.FileReader; import java.io.BufferedReader; public class JavaBufferedReader { public static void main(String[] args) { try { FileReader fr = new FileReader("JavaFile.txt"); BufferedReader br = new BufferedReader(fr); String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (Exception ex) { System.out.println(ex.getMessage()); } } } |
The java.io.BufferedReader.readline() method read a line of text. A line is considered to be terminated by any one of a line feed (‘\n’), a carriage return (‘\r’), or a carriage return followed immediately by a linefeed.
Syntax : public String readline().