PipedInputStream read Example

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


PipedInputStream class read example. PipedInputSpublic int read(byte[],int ,int) throws IOException Reads up to len bytes of data from this piped input stream into an array of bytes.tream class read example.

Here is the code

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

public class Read1 {

    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, 05);

        //Reads byte from piped input stream.
        System.out.println(piStream.read(b, 05));

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

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

Output
5

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

HOME | COPYRIGHT | CONTACT US