Skip to content
Related Articles

Related Articles

StringReader markSupported() method in Java with Examples
  • Last Updated : 13 Feb, 2019

The markSupported() method of StringReader Class in Java is used to check whether this StringReader is supports mark() operation or not. It returns a boolean which states if the reader is mark supported.

Syntax:

public boolean markSupported()

Parameters: This method does not accepts any parameters

Return Value: This method returns a boolean value which tells if this StringReader supports mark() operation or not. It return true if it is markSupported. Else it returns false.

Below methods illustrates the working of markSupported() method:



Program 1:




// Java program to demonstrate
// StringReader markSupported() method
  
import java.io.*;
import java.util.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        try {
            String str = "GeeksForGeeks";
  
            // Create a StringReader instance
            StringReader reader
                = new StringReader(str);
  
            // Check if the StringReader is
            // markSupported using markSupported()
            System.out.println("Is StringReader markSupported: "
                               + reader.markSupported());
  
            reader.close();
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}
Output:
Is StringReader markSupported: true

Program 2:




// Java program to demonstrate
// StringReader markSupported() method
  
import java.io.*;
import java.util.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        try {
            String str = "GeeksForGeeks";
  
            // Create a StringReader instance
            StringReader reader
                = new StringReader(str);
  
            // Check if the StringReader is
            // markSupported using markSupported()
            System.out.println("Is StringReader markSupported: "
                               + reader.markSupported());
  
            reader.close();
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}
Output:
Is StringReader markSupported: true

Reference: https://docs.oracle.com/javase/9/docs/api/java/io/StringReader.html#markSupported–

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :