Java.io.FilterReader.markSupported() 方法
描述
java.io.FilterReader.mark(int readAheadLimit) 方法告诉该流是否支持 mark() 操作。
声明
以下是 java.io.FilterReader.markSupported() 方法的声明 −
public boolean markSupported()
参数
NA
返回值
如果此流支持标记操作,则此方法返回 true。
异常
NA
示例
下面的例子展示了 java.io.FilterReader.markSupported() 方法的使用。
package com.tutorialspoint;
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

