PipedWriter flush Example

PipedWriter class flush example. This example shows you how to use flush method.


PipedWriter class flush example.public void flush() throws IOException Flushes this output stream and forces any buffered output characters to be written out. This will notify any readers that characters are waiting in the pipe.

Here is the code

/**
 * @ # Flush.java
 * A class repersenting use to flush method 
 * of PipedWriter class in java.io package
 * version 30 May 2008
 * author Rose India 
 */
import java.io.*;

public class Flush {
    public  static void main(String args[])throws Exception{
                // Create a new instance of a PipedWriter object.
        PipedWriter writer = new PipedWriter();

        // Connect the PipedWriter to a PipedReader object.
        PipedReader reader = new PipedReader();
        writer.connect(reader);

        // Read from the PipedWriter.
        writer.write("RoseIndia.net");
        writer.flush();

        while (reader.ready()) {
            System.out.print((charreader.read());
        }

        // Close the PipedReader and PipedWriter.
        reader.close();
        writer.close();
    }
}

Output
RoseIndia.net

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US