PipedInputStream close Example

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


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

Here is the code

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

public class Close {

    public static void main(String args[]) throws Exception {
        byte[] b = {12345};
        PipedOutputStream poStream = new PipedOutputStream();
        PipedInputStream piStream = new PipedInputStream();

        //piped input stream connect to the piped output stream 
        piStream.connect(poStream);

        //Writes specified byte array.
        poStream.write(b, 04);

        //number of bytes that can be read from this input stream.
        System.out.println("No. of byte Available " + piStream.available());

        // Closes piped input stream
        poStream.close();

        // Closes piped output stream
        piStream.close();
    }
}

Output
No. of byte Available 4

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

HOME | COPYRIGHT | CONTACT US