Survey							
                            
		                
		                * Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
PUBLIC VOID CLOSE METHOD
http://www.tutorialspoint.com/java/io/filterinputstream_close.htm
Copyright © tutorialspoint.com
Description
The java.io.FilterInputStream.close method closes this input stream and releases any system
resources associated with the stream.
Declaration
Following is the declaration for public void close method:
public void close()
Parameters
NA
Return Value
The method does not return any value.
Exception
IOException -- If an I/O error occurs.
Example
The following example shows the usage of public void close method.
package com.tutorialspoint;
import
import
import
import
import
java.io.BufferedInputStream;
java.io.FileInputStream;
java.io.FilterInputStream;
java.io.IOException;
java.io.InputStream;
public class FilterInputStreamDemo {
public static void main(String[] args) throws Exception {
InputStream is = null;
FilterInputStream fis = null;
try{
// create input streams
is = new FileInputStream("C://test.txt");
fis = new BufferedInputStream(is);
// closes and releases the associated system resources
fis.close();
// read is called after close() invocation
fis.read();
}catch(IOException e){
System.out.print("stream is closed prior ot this call");
}finally{
// releases any system resources associated with the stream
if(is!=null)
is.close();
if(fis!=null)
fis.close();
}
}
}
Assuming we have a text file c:/test.txt, which has the following content. This file will be used as
an input for our example program:
ABCDEF
Let us compile and run the above program, this will produce the following result:
stream is closed prior ot this call
Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js