Java BufferedReader ready() method example

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

java.io.BufferedReader ready()

Description :

This java tutorial shows how to use the ready() method of Scanner class of java.io package. This method returns a boolean data type, true if the buffer is not empty which signifies that the stream is ready to be read otherwise false.

Method Syntax :

public boolean ready() throws IOException

Parameter Input :

DataType Parameter Description
N/A N/A N/A

Method Returns :

This method simply returns true true if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.

Compatibility Version :

Requires Java 1.1 and up

Exception :

None

Discussion :

The BufferedReader ready() method overrides the inherited method of Reader class. This method is used to flag down if the stream is ready to be read.

Java Code Example :

This java example source code demonstrates the use of ready() method of BufferedReader class. Basically the code asks for the user address from the console and then uses the ready method to check if the character stream is ready. If the stream is ready, we then prints out the address using the BufferedReader nextLine() method.

Sample Output :

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

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