Wednesday, July 3, 2024
HomeLanguagesJavaReader markSupported() method in Java with Examples

Reader markSupported() method in Java with Examples

The markSupported() method of Reader Class in Java is used to check whether this Reader 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 Reader 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
// Reader markSupported() method
  
import java.io.*;
import java.util.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        try {
  
            String str = "GeeksForGeeks";
  
            // Create a Reader instance
            Reader reader
                = new StringReader(str);
  
            // Check if the Reader is
            // markSupported using markSupported()
            System.out.println("Is Reader markSupported: "
                               + reader.markSupported());
  
            reader.close();
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}


Output:

Is Reader markSupported: true

Program 2:




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


Output:

Is Reader markSupported: true

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

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments