PipedOutputStream write Example

PipedOutputStream class write example. This example shows you how to use write method.


PipedOutputStream class write example. public void write(int b) throws IOException Writes the specified byte to the piped output stream.

Here is the code

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

public class Write1 {

       public static void main(String args[]) throws Exception {

        PipedOutputStream poStream = new PipedOutputStream();
        PipedInputStream piStream = new PipedInputStream();

        // Connects piped output stream to a receiver.
        poStream.connect(piStream);

        //write byte array
        poStream.write(5);

        //Flushes output stream
        poStream.flush();

        System.out.println("Read from piped input stream");
        while (piStream.available() != 0) {
            System.out.println(piStream.read());
        }

        //Reads the next byte from piped input stream.
        poStream.close();
        piStream.close();
    }
}

Output
5

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

HOME | COPYRIGHT | CONTACT US