InputStream Close() Example

Closes this input stream and releases any system resources associated with the stream.


InputStreamclass Close() method example. This example shows you how to use Close() method.This method Closes this input stream and releases any system resources associated with the stream.

Here is the code:-

/**
 * @Program that Closes this input stream and releases any system resources 
   associated with the stream.
 * Close.java 
 * Author:-RoseIndia Team
 * Date:-06-Jun-2008
 */
import java.io.*;

public class Close extends InputStream {

    public int read() throws IOException {
        return 0;
    }

    public static void main(String[] argsthrows IOException {
        PipedInputStream i = new PipedInputStream();
        OutputStream o = new PipedOutputStream();
        i.connect((PipedOutputStreamo);
        byte[] b = {1234567};
        o.write(b);
    System.out.print("The estimate of the number of bytes that can be read : ");
        while (i.available() != 0) {
    System.out.print(" "+i.read());
        }
    //Closes this input stream
        i.close();
      
    }
}

Output of the Program
 The estimate of the number of bytes that can be read :  1 2 3 4 5 6 7

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

HOME | COPYRIGHT | CONTACT US