PipedReader connect Example
PipedReader class connect example. This example shows you how to use connect method.
PipedReader class connect example.public void connect(PipedWriter) throws IOException Causes this piped reader to be connected to the piped writer src. If this object is already connected to some other piped writer, an IOException is thrown.
Here is the code
/**
* @ # Connect.java
* A class repersenting use to connect method
* of PipedWriter class in java.io package
* version 30 May 2008
* author Rose India
*/
import java.io.*;
public class Connect {
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());
}
// Close the PipedReader and PipedWriter.
reader.close();
writer.close();
}
} |
|