PipedWriter close Example

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


PipedWriter class close example.public void close() throws IOException Closes this piped output stream and releases any system resources associated with this stream. This stream may no longer be used for writing characters.

Here is the code

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

public class Close {

    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