PipedReader close Example

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


PipedReader class close example. public void close() throws IOException Closes this piped stream and releases any system resources associated with the stream.

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[] argsthrows 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((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