public abstract class Reader extends Object implements Readable, Closeable
BufferedReader , LineNumberReader , CharArrayReader , InputStreamReader , FileReader , FilterReader , PushbackReader , PipedReader , StringReader , Writer
| Modifier | Constructor and Description |
|---|---|
protected |
Reader()
创建一个新的字符流阅读器,其关键部分将在阅读器本身上同步。
|
protected |
Reader(Object lock)
创建一个新的字符流阅读器,其关键部分将在给定对象上同步。
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
close()
关闭流并释放与之相关联的任何系统资源。
|
void |
mark(int readAheadLimit)
标记流中的当前位置。
|
boolean |
markSupported()
告诉这个流是否支持mark()操作。
|
int |
read()
读一个字符
|
int |
read(char[] cbuf)
将字符读入数组。
|
abstract int |
read(char[] cbuf, int off, int len)
将字符读入数组的一部分。
|
int |
read(CharBuffer target)
尝试将字符读入指定的字符缓冲区。
|
boolean |
ready()
告诉这个流是否准备好被读取。
|
void |
reset()
重置流。
|
long |
skip(long n)
跳过字符
|
protected Object lock
protected Reader()
protected Reader(Object lock)
lock - 要同步的对象。
public int read(CharBuffer target) throws IOException
read在界面
Readable
target - 读取字符的缓冲区
IOException - 如果发生I / O错误
NullPointerException - 如果target为null
ReadOnlyBufferException - 如果目标是只读缓冲区
public int read()
throws IOException
旨在支持高效单字符输入的子类应该覆盖此方法。
IOException - 如果发生I / O错误
public int read(char[] cbuf)
throws IOException
cbuf - 目的缓冲区
IOException - 如果发生I / O错误
public abstract int read(char[] cbuf,
int off,
int len)
throws IOException
cbuf - 目的缓冲区
off - 开始存储字符的偏移量
len - 要读取的最大字符数
IOException - 如果发生I / O错误
public long skip(long n)
throws IOException
n - 要跳过的字符数
IllegalArgumentException - 如果
n为负数。
IOException - 如果发生I / O错误
public boolean ready()
throws IOException
IOException - 如果发生I / O错误
public boolean markSupported()
public void mark(int readAheadLimit)
throws IOException
readAheadLimit - 限制仍然保留标记时可能读取的字符数。
读了这么多字符后,尝试重置流可能会失败。
IOException - 如果流不支持mark(),或者发生其他I / O错误
public void reset()
throws IOException
IOException - 如果流未被标记,或标记已被无效,或者流不支持reset(),或者发生其他I / O错误
public abstract void close()
throws IOException
close在接口
Closeable
close在界面
AutoCloseable
IOException - 如果发生I / O错误
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.