Description :

This java tutorial shows how to use the readLine() method of BufferedReader class of package. This method returns a line of String which has been read by this BufferedReader.

Method Syntax :

public String readLine() throws IOException

Parameter Input :


DataType Parameter Description


Method Returns :

This method simply returns a line of String which the BufferedReader had read.

Compatibility Version :

Requires Java 1.5 and up

Exception :


– the readLine() method throw the IOException if I/O error occurs.

Discussion :

The readLine method reads a line of text and then it is return as String data type. This method considers the following as a new line

  • line feed (‘\n’)
  • carriage return (‘\r’)
  • carriage return followed immediately by a linefeed.

Java Code Example :

This java example source code demonstrates the use of nextLine() method of BufferedReader class. Basically it gets the user’s console input per line.

Sample Output :

Running the readLine() method example source code of BufferedReader class will give you the following output:

Exception Scenario :


Similar Method :

  • N/A

Suggested Reading List :

References :