Java IO Tutorial - Java Reader.markSupported()








Syntax

Reader.markSupported() has the following syntax.

public boolean markSupported()

Example

In the following code shows how to use Reader.markSupported() method.

/*from   w  ww . j av  a 2s .  com*/
import java.io.*;

public class Main {

   public static void main(String[] args) {

      String s = "tutorial from java2s.com";

      // create a new StringReader
      Reader reader = new StringReader(s);

      try {
         // read the first five chars
         for (int i = 0; i < 5; i++) {
            char c = (char) reader.read();
            System.out.println(c);
         }
         System.out.println(reader.markSupported());
         reader.close();

      } catch (IOException ex) {
         ex.printStackTrace();
      }
   }
}

The code above generates the following result.