java.io.BufferedReader markSupported()

Description :

This java tutorial shows how to use the markSupported() method of BufferedReader class of java.io package. This method returns true if mark() operation of the same BufferedReader class were supported. This method overrides the markSupported() method of Reader class.

Method Syntax :

public boolean markSupported()

Parameter Input :

 

DataType Parameter Description
N/A N/A N/A

 

Method Returns :

This method simply returns true if the underlying stream is supporting the mark() operation otherwise false.

Compatibility Version :

Requires Java 1.1 and up

Exception :

None

Java Code Example :

This java example source code demonstrates the use of markSupported() method of BufferedReader class.

package com.javatutorialhq.java.examples;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * Java example source code that uses the markSupported() method of
 * BufferedReader class
 */

public class BufferedReaderMarkSupported {

	public static void main(String[] args) {
		System.out.print("What is your name? ");
		// declare the BufferedReader Class
		// used the InputStreamReader to read the console input
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		try {
			reader.read();
			System.out.println("mark supported?" + reader.markSupported());
			// close the BufferedReader object
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

Sample Output :

Running the markSupported() method example source code of BufferedReader class will give you the following output

What is your name? Albert
mark supported?true

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :