Java FilterReader.markSupported()方法範例

2019-10-16 22:13:34

FilterReader.markSupported()方法範例

FilterReader.markSupported()具有以下語法。

public boolean markSupported()

範例

在下面的程式碼中展示了如何使用FilterReader.markSupported()方法。

import java.io.FilterReader;
import java.io.Reader;
import java.io.StringReader;
// by w  w  W.YIIB AI.c  O  M 
public class Main {
  public static void main(String[] args) throws Exception {

    // create new reader
    Reader r = new StringReader("ABCDEF");

    // create new filter reader
    FilterReader fr = new FilterReader(r) {
    };

    // tests if the filter reader supports mark()
    boolean bool = fr.markSupported();

    // prints
    System.out.print("If mark() supported? " + bool);

  }
}

上面的程式碼生成以下結果。

If mark() supported? true