Open In App

Java.io.FilterReader class in Java

Abstract class for reading filtered character streams. The abstract class FilterReader itself provides default methods that pass all requests to the contained stream. Subclasses of FilterReader should override some of these methods and may also provide additional methods and fields.
Constructor :

Methods:

Program :




//Java program illustrating FilterReader class methods
  
import java.io.*;
class FilterReaderdemo
{
    public static void main(String[] args) throws IOException
    {
        Reader r = new StringReader("GeeksforGeeks");
        FilterReader fr = new FilterReader(r) 
        {
        };
        char ch[] = new char[8];
          
        //illustrating markSupported()
        if(fr.markSupported())
        {
            //illustrating mark() method
            System.out.println("mark method is supported");
            fr.mark(100);
        }
          
        //illustrating skip() method
        fr.skip(5);
          
        //illustrating ready()
        if(fr.ready())
        {
            //illustrating read(char[] cbuff,int off,int len)
            fr.read(ch);
            for (int i = 0; i < 8; i++) 
            {
                System.out.print(ch[i]);
            }
              
            //illustrating reset()
            fr.reset();
            for (int i = 0; i <5 ; i++)
            {
                //illustrating read()
                System.out.print((char)fr.read());
            }
        }
          
        //closing the stream
        fr.close();
    }
}

Output :

mark method is supported
forGeeksGeeks

Article Tags :