- BufferedReader helps us improve file reading performance
- BufferedReader gives us the readLine() method to read the content line by line.
- It makes the performance fast.
Java BufferedReader Example
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class A{
public static void main(String[] args) {
try {
FileReader fr = new FileReader
("C:\\Users\\Rajendra\\Desktop\\Raj.txt");
BufferedReader br = new BufferedReader(fr);
for (int i = 0; i < 4; i++) {
System.out.println(br.readLine());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
You Also Learn –
- What is Abstract Class in Java
- What is Lambda Expression in Java 8
- What is Exception Handling in Java
- Types of Exceptions in Java
- What is inheritance in Java
- What is the Final Keyword in Java
- What is Interface in Java
- What is Wrapper Class in Java
- Break Keywords in Java with Example
- What is Method In Java With Example
- What is Constructor in Java With Example
- What is Polymorphism in java
- What is a non-static variable in java
- Types of access specifiers in java
- What is the local variable in java
- Types of loops in java with program
- Remove duplicate elements in an Array in java
- What is var type in java
- What is a static variable in java
- What is the difference between return and return value?