Java BufferedReader readLine() method example

HQ ┬╗ Java Tutorial ┬╗ java.io ┬╗ BufferedReader ┬╗ Java BufferedReader readLine() method example
Java BufferedReader readLine() method example 2018-02-16T07:27:50+00:00

java.io.BufferedReader readLine()

Description :

This java tutorial shows how to use the readLine() method of BufferedReader class of java.io 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
N/A N/A N/A

Method Returns :

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

Compatibility Version :

Requires Java 1.5 and up

Exception :

IOException

– 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 :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :

Contact Info

Singapore

Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close