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
-如果目标是空的
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.