Java IO Tutorial - Java BufferedInputStream.close()








Syntax

BufferedInputStream.close() has the following syntax.

public void close()  throws IOException

Example

In the following code shows how to use BufferedInputStream.close() method.

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
/*from  ww w.j  ava2 s  .c  o m*/
public class Main {
  public static void main(String[] args) throws Exception {

    InputStream inStream = new FileInputStream("c:/test.txt");
    BufferedInputStream bis = new BufferedInputStream(inStream);

    int byteNum = bis.available();

    System.out.println(byteNum);

    bis.close();

    byteNum = bis.available();
    System.out.println(byteNum);

  }
}