27. Which of the following statement will create a stream to read text from "a.txt" file line by line? 1. FileReader fr=new FileReader("a.txt"); 2. BufferedReader br=new BufferedReader(new FileReader("a.txt")); 3. FileInputStream fis=new FileInputStream("a.t (A) 1 (B) 2 (C) 3 (D) none
Answers
Answered by
4
Answer:
Explanation:
How to read file in Java – BufferedReader
author image
By mkyong | Last updated: April 9, 2019
Answered by
1
Answer:
The correct answer is option 2) BufferedReader br=new BufferedReader(new FileReader ("a.txt"))
Explanation:
- A Java class called BufferedReader reads text from the input stream. To read characters, arrays, etc. efficiently, it buffers the characters.
- Since we can use the readline() function to read the data one line at a time, it inherits the reader class and makes the code efficient.
- It enables the efficient reading of characters, arrays, and lines by buffering text as it is read from a character-input stream.
#SPJ3
Similar questions
Social Sciences,
1 day ago
English,
1 day ago
Biology,
1 day ago
English,
8 months ago
Hindi,
8 months ago