Java.io.Reader.markSupported() 方法


Java.io.Reader.markSupported() 方法

package com.codingdict;



import java.io.*;



public class ReaderDemo {



   public static void main(String[] args) {

      String s = "Hello World";



      // 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.print("" + c);

         }



         // change line

         System.out.println();



         // check if mark is supported

         System.out.println("" + reader.markSupported());



         // close the stream

         reader.close();



      } catch (IOException ex) {

         ex.printStackTrace();

      }

   }

}