Java InputStreamReader.close()
Syntax
InputStreamReader.close() has the following syntax.
public void close() throws IOException
Example
In the following code shows how to use InputStreamReader.close() method.
/*from w w w . ja v a 2 s . c o m*/
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("C:/test.txt");
InputStreamReader isr = new InputStreamReader(fis);
// input stream reader is closed
isr.close();
System.out.print("close() invoked");
// read() called after closed method
int i = isr.read();
char c = (char) i;
System.out.println(c);
}
}
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »