Java FilterReader.close()
Syntax
FilterReader.close() has the following syntax.
public void close() throws IOException
Example
In the following code shows how to use FilterReader.close() method.
import java.io.FilterReader;
import java.io.Reader;
import java.io.StringReader;
// www .java 2 s .c om
public class Main {
public static void main(String[] args) throws Exception {
int i = 0;
Reader r = new StringReader("ABCDEFG");
// create new filter reader
FilterReader fr = new FilterReader(r) {
};
// read till the end of the stream
while ((i = fr.read()) != -1) {
char c = (char) i;
System.out.println(c);
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »