PipedReader ready Example
PipedReader class ready example. This example shows you how to use ready method.
PipedReader class ready example. public boolean ready() throws IOException Tell whether this stream is ready to be read. A piped character stream is ready if the circular buffer is not empty.
Here is the code
/**
* @ # Ready.java
* A class repersenting use to ready method
* of PipedWriter class in java.io package
* version 30 May 2008
* author Rose India
*/
import java.io.*;
public class Ready {
public static void main(String args[]) throws Exception {
// Create a new instance of a PipedReader object.
PipedReader reader = new PipedReader();
// Connect the PipedReader to a PipedWriter object.
PipedWriter writer = new PipedWriter();
reader.connect(writer);
// Read from the PipedWriter.
writer.write("RoseIndia.net");
while (reader.ready()) {
System.out.print((char) reader.read());
}
}
} |
|