Java.io.BufferedReader Class in Java Last Updated : 03 May, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. In general, each read request made by a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is therefore advisable to wrap a BufferedReader around any Reader whose read() operations may be costly, such as FileReaders and InputStreamReaders. Programs that use DataInputStreams for textual input can be localized by replacing each DataInputStream with an appropriate BufferedReader. Constructors of BufferedReader Class ConstructorAction PerformedBufferedReader(Reader in)Creates a buffering character-input stream that uses a default-sized input bufferBufferedReader(Reader in, int sz)Creates a buffering character-input stream that uses an input buffer of the specified size.Methods of BufferedReader ClassMethod NameAction close()Closes the stream and releases any system resources associated with it.Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.mark()Marks the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point.markSupported()Tells whether this stream supports the mark() operation, which it does.read()Reads a single character.read(char[] cbuf, int off, int len)Reads characters into a portion of an array. This method implements the general contract of the corresponding read method of the Reader class. As an additional convenience, it attempts to read as many characters as possible by repeatedly invoking the read method of the underlying stream.readLine()Reads 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 line feed.ready()Tells whether this stream is ready to be read.reset()Resets the stream to the most recent mark.skip(long)Skips characters. Implementation: The content inside the file is as follows: This is first line this is second line Example Java // Java Program to Illustrate BufferedReader Class // Via Its Methods // Importing required classes import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; // Class class GFG { // Main driver method public static void main(String[] args) throws IOException { // Creating object of FileReader and BufferedReader // class FileReader fr = new FileReader("file.txt"); BufferedReader br = new BufferedReader(fr); char c[] = new char[20]; // Illustrating markSupported() method if (br.markSupported()) { // Print statement System.out.println( "mark() method is supported"); // Illustrating mark method br.mark(100); } // File Contents is as follows: // This is first line // this is second line // Skipping 8 characters br.skip(8); // Illustrating ready() method if (br.ready()) { // Illustrating readLine() method System.out.println(br.readLine()); // Illustrating read(char c[],int off,int len) br.read(c); for (int i = 0; i < 20; i++) { System.out.print(c[i]); } System.out.println(); // Illustrating reset() method br.reset(); for (int i = 0; i < 8; i++) { // Illustrating read() method System.out.print((char)br.read()); } } } } Output: mark() method is supported first line this is second line This is Comment More infoAdvertise with us Next Article Java.io.BufferedReader Class in Java K kartik Improve Article Tags : Java Java-I/O Java-Classes Practice Tags : Java Similar Reads Java Tutorial Java is a high-level, object-oriented programming language used to build web apps, mobile applications, and enterprise software systems. It is known for its Write Once, Run Anywhere capability, which means code written in Java can run on any device that supports the Java Virtual Machine (JVM).Java s 10 min read Java OOP(Object Oriented Programming) Concepts Java Object-Oriented Programming (OOPs) is a fundamental concept in Java that every developer must understand. It allows developers to structure code using classes and objects, making it more modular, reusable, and scalable.The core idea of OOPs is to bind data and the functions that operate on it, 13 min read Java Interview Questions and Answers Java is one of the most popular programming languages in the world, known for its versatility, portability, and wide range of applications. Java is the most used language in top companies such as Uber, Airbnb, Google, Netflix, Instagram, Spotify, Amazon, and many more because of its features and per 15+ min read Arrays in Java Arrays in Java are one of the most fundamental data structures that allow us to store multiple values of the same type in a single variable. They are useful for storing and managing collections of data. Arrays in Java are objects, which makes them work differently from arrays in C/C++ in terms of me 15+ min read Collections in Java Any group of individual objects that are represented as a single unit is known as a Java Collection of Objects. In Java, a separate framework named the "Collection Framework" has been defined in JDK 1.2 which holds all the Java Collection Classes and Interface in it. In Java, the Collection interfac 15+ min read Inheritance in Java Java Inheritance is a fundamental concept in OOP(Object-Oriented Programming). It is the mechanism in Java by which one class is allowed to inherit the features(fields and methods) of another class. In Java, Inheritance means creating new classes based on existing ones. A class that inherits from an 13 min read Java Exception Handling Exception handling in Java allows developers to manage runtime errors effectively by using mechanisms like try-catch block, finally block, throwing Exceptions, Custom Exception handling, etc. An Exception is an unwanted or unexpected event that occurs during the execution of a program, i.e., at runt 10 min read Java Programs - Java Programming Examples In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its 8 min read Java Interface An Interface in Java programming language is defined as an abstract type used to specify the behaviour of a class. An interface in Java is a blueprint of a behaviour. A Java interface contains static constants and abstract methods. Key Properties of Interface:The interface in Java is a mechanism to 12 min read Introduction to Java Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is platform-independent, which means we can write code once and run it anywhere using the Java Virtual Machine (JVM). Java is mostly used for building desktop applications, web applications, Android 4 min read Like