BufferedReader readLine() method in Java with Examples Last Updated : 28 May, 2020 Comments Improve Suggest changes Like Article Like Report The readLine() method of BufferedReader class in Java is used to read one line text at a time. The end of a line is to be understood by '\n' or '\r' or EOF. Syntax: public String readLine() throws IOException Parameters: This method does not accept any parameter. Return value: This method returns the String that is read by this method and excludes any termination symbol available. If the buffered stream has ended and there is no line to be read then this method returns NULL. Exceptions: This method throws IOException if an I/O error occurs. Below programs illustrate readLine() method in BufferedReader class in IO package: Program 1: Assume the existence of the file "c:/demo.txt". Java // Java program to illustrate // BufferedReader readLine() method import java.io.*; public class GFG { public static void main(String[] args) { // Read the stream 'demo.txt' // containing text // "GEEKS" // "FOR" // "GEEKS" FileReader fileReader = new FileReader( "c:/demo.txt"); // Convert fileReader to // bufferedReader BufferedReader buffReader = new BufferedReader( fileReader); while (buffReader.ready()) { System.out.println( buffReader.readLine()); } } } Input: Output: Program 2: Assume the existence of the file "c:/demo.txt". Java // Java program to illustrate // BufferedReader readLine() method import java.io.*; public class GFG { public static void main(String[] args) { // Read the stream 'demo.txt' // containing text // "GEEKSFORGEEKS" // "geeksforgeeks" FileReader fileReader = new FileReader( "c:/demo.txt"); // Convert fileReader to // bufferedReader BufferedReader buffReader = new BufferedReader( fileReader); while (buffReader.ready()) { System.out.println( buffReader.readLine()); } } } Input: Output: References: https://docs.oracle.com/javase/10/docs/api/java/io/BufferedReader.html#readLine() Comment More infoAdvertise with us Next Article BufferedReader readLine() method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-Functions Java-IO package Practice Tags : Java Similar Reads BufferedReader reset() method in Java with Examples The reset() method of BufferedReader class in Java is used to fix or mark the position at the last marked position so that the same byte can be read again. Syntax: public void reset() throws IOException Overrides: It overrides the reset() method of Reader class. Parameters: The method does not accep 3 min read BufferedInputStream read() method in Java with Examples read() method of BufferedInputStream class in Java is used to read the next byte of data from the input stream. When this read() method is called on the input stream then this read() method reads one character of the input stream at a time. Syntax: public int read() Overrides: It overrides read() me 3 min read BufferedReader mark() method in Java with Examples The mark() method of BufferedReader class in Java is used to mark the current position in the buffer reader stream. The reset() method of the same BufferedReader class is also called subsequently, after the mark() method is called. The reset() method fixes the position at the last marked position so 3 min read BufferedReader close() method in Java with Examples The close() method of BufferedReader class in Java is used to close the stream and release all the system resources associated with the stream operations. Syntax: public void close() throws IOException Parameters: This method does not accept any parameter. Return value: This method does not return a 2 min read CharBuffer read() methods in Java with Examples The read() method of java.nio.CharBuffer Class is used to read characters into the specified character buffer. The buffer is used as a repository of characters as-is: the only changes made are the results of a put operation. No flipping or rewinding of the buffer is performed. Syntax: public int rea 4 min read CharArrayReader read() method in Java with Examples The read() method of CharArrayReader Class in Java is used to read a single character from the stream. This method blocks the stream till: It has taken some input from the stream. Some IOException has occurred It has reached the end of the stream while reading. This method is declared as abstract me 3 min read BufferedReader Class lines() method in Java with Examples BufferedReader.lines() is the method of the Java Buffered Reader Class in the Java Library which returns lines in terms of Stream and from this Buffered Reader class. With the help of the stream, there are a lot of methods that mimic the output according to our needs. Syntax: BufferedReader.lines() 2 min read Console readLine() method in Java with Examples The readLine() method of Console class in Java is of two types: 1. The readLine() method of Console class in Java is used to read a single line of text from the console. Syntax: public String readLine() Parameters: This method does not accept any parameter. Return value: This method returns the stri 3 min read Reader read(CharBuffer) method in Java with Examples The read(CharBuffer) method of Reader Class in Java is used to read the specified characters into a CharBuffer instance. This method blocks the stream till: It has taken some input from the stream. Some IOException has occurred It has reached the end of the stream while reading. Syntax: public int r 2 min read Like