java.lang.Objectjava.io.Reader
java.io.FilterReader
public abstract class FilterReader
用于读取已过滤的字符流的抽象类。抽象类 FilterReader 自身提供了一些将所有请求传递给所包含的流的默认方法。FilterReader 的子类应重写这些方法中的一些方法,并且还可以提供一些额外的方法和字段。
| 字段摘要 | |
|---|---|
protected Reader |
in 底层字符输入流。 |
| 从类 java.io.Reader 继承的字段 |
|---|
lock |
| 构造方法摘要 | |
|---|---|
protected |
FilterReader(Reader in) 创建一个新的 filtered reader。 |
| 方法摘要 | |
|---|---|
void |
close() 关闭该流并释放与之关联的所有资源。 |
void |
mark(int readAheadLimit) 在流中的当前位置上作标记。 |
boolean |
markSupported() 判断此流是否支持 mark() 操作。 |
int |
read() 读取单个字符。 |
int |
read(char[] cbuf, int off, int len) 将字符读入数组的某一部分。 |
boolean |
ready() 判断此流是否已经准备好用于读取。 |
void |
reset() 重置该流。 |
long |
skip(long n) 跳过某些字符。 |
| 从类 java.io.Reader 继承的方法 |
|---|
read, read |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected Reader in
| 构造方法详细信息 |
|---|
protected FilterReader(Reader in)
in - 提供底层流的 Reader 对象。
NullPointerException - 如果
in 为
null
| 方法详细信息 |
|---|
public int read()
throws IOException
IOException - 如果发生 I/O 错误
public int read(char[] cbuf,
int off,
int len)
throws IOException
cbuf - 目标缓冲区
off - 开始存储字符处的偏移量
len - 要读取的最多字符数
IOException - 如果发生 I/O 错误
public long skip(long n)
throws IOException
n - 要跳过的字符数
IOException - 如果发生 I/O 错误
public boolean ready()
throws IOException
IOException - 如果发生 I/O 错误
public boolean markSupported()
Reader 中的
markSupported
public void mark(int readAheadLimit)
throws IOException
readAheadLimit - 在仍保留该标记的情况下,对可读取字符数量的限制。在读取这样多的字符后,尝试重置流可能会失败。
IOException - 如果发生 I/O 错误
public void reset()
throws IOException
IOException - 如果发生 I/O 错误
public void close()
throws IOException