目录

boolean markSupported()

描述 (Description)

java.io.FilterReader.mark(int readAheadLimit)方法告知此流是否支持mark()操作。

声明 (Declaration)

以下是java.io.FilterReader.markSupported()方法的声明 -

public boolean markSupported()

参数 (Parameters)

NA

返回值 (Return Value)

如果此流支持标记操作,则此方法返回true。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.io.FilterReader.markSupported()方法的用法。

package com.iowiki;
import java.io.FilterReader;
import java.io.Reader;
import java.io.StringReader;
public class FilterReaderDemo {
   public static void main(String[] args) throws Exception {
      FilterReader fr = null;
      Reader r = null;      
      boolean bool = false;
      try {
         // create new reader
         r = new StringReader("ABCDEF");
         // create new filter reader
         fr = new FilterReader(r) {
         };
         // tests if the filter reader supports mark()
         bool = fr.markSupported();
         // prints
         System.out.print("If mark() supported? "+bool);
      } catch(Exception e) {
         // if any I/O error occurs
         e.printStackTrace();
      } finally {
         // releases system resources associated with this stream
         if(r!=null)
            r.close();
         if(fr!=null)
            fr.close();
      }
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

If mark() supported? true
↑回到顶部↑
WIKI教程 @2018