Java IO Tutorial - Java FilterReader.ready()








Syntax

FilterReader.ready() has the following syntax.

public boolean ready()  throws IOException

Example

In the following code shows how to use FilterReader.ready() method.

/*from   w  w w.  ja v a2s .c  o m*/
import java.io.FilterReader;
import java.io.Reader;
import java.io.StringReader;

public class Main {
  public static void main(String[] args) throws Exception {

    Reader r = new StringReader("ABCDEF");

    // create new filter reader
    FilterReader fr = new FilterReader(r) {
    };

    // true if the filter reader is ready to be read
    boolean bool = fr.ready();

    // prints
    System.out.println("Ready to read? " + bool);

  }
}

The code above generates the following result.