PipedInputStream connect Example
PipedInputStream class connect example. This example shows you how to use connect method.
PipedInputStream class connect example. public void connect(PipedOutputStream) throws IOException Causes this piped input stream to be connected to the piped output stream src. If this object is already connected to some other piped output stream, an IOException is thrown
Here is the code
/**
* @ # Connect.java
* A class repersenting use to Connect method
* of PipedInputStream class in java.io package
* version 03 June 2008
* author Rose India
*/
import java.io.*;
public class Connect {
public static void main(String args[]) throws Exception {
byte[] b = {1, 2, 3, 4, 5};
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, 0, 4);
//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();
}
} |
|