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 = {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();
}
} |
|