Java.io.BufferedReader Class in Java Last Updated : 03 May, 2022 Comments Improve Suggest changes 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 N Nishant Sharma Improve Article Tags : Java Java-I/O Java-Classes Practice Tags : Java Similar Reads Java.io.BufferedInputStream class in Java A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the mark and reset methods. When the BufferedInputStream is created, an internal buffer array is created. As bytes from the stream are read or skipped, the internal buffer is refil 4 min read Java.io.BufferedWriter class methods in Java Bufferreader class writes text to character-output stream, buffering characters.Thus, providing efficient writing of single array, character and strings. A buffer size needs to be specified, if not it takes Default value. An output is immediately set to the underlying character or byte stream by the 5 min read Java BufferedReader vs Scanner Class Java provides several classes for reading input, but two of the most commonly used are Scanner and BufferedReader. The main difference between Scanner and BufferedReader is:Scanner class provides parsing and input reading capabilities with built-in methods for different data types.BufferedReader cla 2 min read java.nio.Buffer Class in Java The Buffer class provides a buffer or a container for data chunks of specific primitive types. A finite sequence of elements is stored linearly in a buffer. Important properties of a buffer that make it convenient to perform read and write operations in the data are: Capacity: This property determin 4 min read Java.io.ByteArrayInputStream class in Java ByteArrayInputStream class of java.io package contains all the buffers, containing bytes to be read from the Input Stream. There is no IO exception in case of ByteArrayInputStream class methods. Methods of this class can be called even after closing the Stream, there is no effect of it on the class 3 min read Like