Java BufferedReader read() method example

HQ ┬╗ Java Tutorial ┬╗ ┬╗ BufferedReader ┬╗ read() method example
Java BufferedReader read() method example 2018-02-16T07:27:51+00:00 read()

Description :

This java tutorial shows how to use the read() method of BufferedReader class of package. This method reads a single character and converted it into int as a method return. This BufferedReader method is widely used in reading characters from the InputStream as input on this class constructor.

Method Syntax :

public int read() throws IOException

Parameter Input :

DataType Parameter Description

Method Returns :

The Scanner read() method return the int equivalent of character read by the BufferedReader’s object. The int return range from 0 to 65535. If there is no character to be read because it already reaches the end of the stream, the method returns -1.

Compatibility Version :

Requires Java 1.1 and up

Exception :


– This method will throw IOException if the operation encounter an I/O exception.

Discussion :

The read() method of BufferedReader class is inherited from Reader class which is the parent of BufferedReader. This reader class is widely used usually in reading characters either from a file or from the console.

Java Code Example :

This java example source code demonstrates the use of read() method of BufferedReader class. Basically it just reads a character from the console input of the user and then prints the result in int data type and also in char data type. This is only a simple program that can be modified to a more complex logic, however for you to appreciate the use of this method, below is for beginner’s example of read() method.

Sample Output :

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

java BufferedReader read method example

java BufferedReader read method example

Exception Scenario :


Similar Method :

  • N/A

Suggested Reading List :

References :

Contact Info


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.