Java BufferedReader Class

Last Updated : 27 Jan 2026

The BufferedReader class in Java is used to read text efficiently from a character-based input stream.

In this chapter, we will learn what the BufferedReader class is, why it is used, its declaration, constructors, important methods, and how to read data from files and the console using examples.

What is BufferedReader Class in Java?

The BufferedReader class is a character-based input stream that provides buffering for another Reader, making the reading process faster and more efficient.

It is commonly used to read text data line by line using the readLine() method. By reducing the number of direct I/O operations, it improves performance when reading large amounts of text. The BufferedReader class extends the Reader class.

BufferedReader Class Declaration

The following declaration shows how the BufferedReader class is defined:

Constructors of BufferedReader Class

The BufferedReader class provides constructors to create a buffered character input stream.

1. BufferedReader(Reader rd)

This constructor creates a buffered reader that uses the default buffer size.

Syntax:

Here is the syntax:

2. BufferedReader(Reader rd, int size)

This constructor creates a buffered reader with a specified buffer size.

Syntax:

Here is the syntax:

Example of BufferedReader Class Constructors

The following code shows how the constructors of the BufferedReader class are used.

Methods of BufferedReader Class

The BufferedReader class provides methods to read character data efficiently.

MethodDescription
int read()It is used for reading a single character.
int read(char[] cbuf, int off, int len)It is used for reading characters into a portion of an array.
boolean markSupported()It is used to test the input stream support for the mark and reset method.
String readLine()It is used for reading a line of text.
boolean ready()It is used to test whether the input stream is ready to be read.
long skip(long n)It is used for skipping the characters.
void reset()It repositions the stream at a position the mark method was last called on this input stream.
void mark(int readAheadLimit)It is used for marking the present position in a stream.
void close()It closes the input stream and releases any of the system resources associated with the stream.

Examples of Java BufferedReader Class

The following examples demonstrate different ways to read data using the Java BufferedReader class.

Example 1: Reading Data from a File Using BufferedReader

The following example demonstrates how to read text from a file using the BufferedReader class.

File Content (testout.txt):

Welcome to TpointTech.

Output:

Welcome to TpointTech.

Example 2: Reading Data from Console Using BufferedReader

The following example demonstrates how to read input from the console using InputStreamReader and BufferedReader.

Output:

Enter your name:
Nakul Jain
Welcome Nakul Jain