Signup/Sign In

Java CharArrayReader markSupported() Method

In this tutorial, we will learn about the markSupported() method of the CharArrayReader class in Java. This method verifies whether the stream supports the mark() method or not. The char array reader supports the mark() method.

Syntax

No parameter is needed in this method and its return type is boolean, which returns true if mark() method can be called if not, it returns false.

public boolean markSupported()

Example 1: CharArrayReader markSupport

In this example, we will demonstrate how to use the markSupported() method, we use this method to check whether the stream supports the mark method or not. When we call this method it will return true if the stream supports the mark() method and returns false if it does not supports the mark() method.

import java.io.CharArrayReader;
class StudyTonight
{
	public static void main(String[] args)  
	{ 
		try 
		{ 
			char[] str = {'H', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'}; 	  
			CharArrayReader reader = new CharArrayReader(str); 	  
			System.out.println("Is CharArrayReader markSupported: "+ reader.markSupported()); 	  
			reader.close(); 
		} 
		catch (Exception e) 
		{ 
			System.out.println("Error: "+e.toString()); 
		} 
	} 
}


Is CharArrayReader markSupported: true

Example 1: CharArrayReader markSupport

Here we will use the markSupported() method to check if the current stream supports the mark() method, When we call this method it will return true if the stream supports the mark() method and returns false if it does not supports mark() method.

import java.io.CharArrayReader;
class StudyTonight
{
	public static void main(String[] args)  
	{ 
		char[] ch = {'H', 'e', 'l', 'l', 'o'};  
		CharArrayReader charArrayReader = new CharArrayReader(ch);  
		boolean bool = charArrayReader.markSupported();  
		System.out.println("Is mark supported : " + bool);  
	} 
}


Is mark supported : true

Conclusion:

In this tutorial, we learned about the markSupported() method of the CharArrayReader class in Java, which is used to check if the current stream supports the invocation of the mark() method or not.



About the author:
I am the founder of Studytonight. I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development.