public class CharArrayReader extends Reader
| Modifier and Type | Field and Description |
|---|---|
protected char[] |
buf
字符缓冲区。
|
protected int |
count
这个缓冲区结束的索引。
|
protected int |
markedPos
标记在缓冲区中的位置。
|
protected int |
pos
当前的缓冲位置。
|
| Constructor and Description |
|---|
CharArrayReader(char[] buf)
从指定的字符数组中创建CharArrayReader。
|
CharArrayReader(char[] buf, int offset, int length)
从指定的字符数组中创建CharArrayReader。
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭流并释放与之相关联的任何系统资源。
|
void |
mark(int readAheadLimit)
标记流中的当前位置。
|
boolean |
markSupported()
告诉这个流是否支持mark()操作。
|
int |
read()
读一个字符
|
int |
read(char[] b, int off, int len)
将字符读入数组的一部分。
|
boolean |
ready()
告诉这个流是否准备好被读取。
|
void |
reset()
将流重新设置为最近的标记,或将其重新设置为从未被标记的开始。
|
long |
skip(long n)
跳过字符
|
protected char[] buf
protected int pos
protected int markedPos
protected int count
public CharArrayReader(char[] buf)
buf - 输入缓冲区(未复制)
public CharArrayReader(char[] buf,
int offset,
int length)
结果的读者将在给定的offset开始阅读。 从该读者可以读取的总数为char的值将为length或buf.length-offset ,以较小者为准。
buf - 输入缓冲区(未复制)
offset - 要读取的第一个字符的偏移量
length - 要读取的字符数
IllegalArgumentException - 如果
offset为负数或大于
buf.length ,或
length为负,或者这两个值之和为负数。
public int read()
throws IOException
read在
Reader
IOException - 如果发生I / O错误
public int read(char[] b,
int off,
int len)
throws IOException
read在类别
Reader
b - 目的缓冲区
off - 开始存储字符的偏移量
len - 要读取的最大字符数
IOException - 如果发生I / O错误
public long skip(long n)
throws IOException
skip在类别
Reader
n - 要跳过的字符数
IOException - 如果流关闭,或发生I / O错误
public boolean ready()
throws IOException
ready在类别
Reader
IOException - 如果发生I / O错误
public boolean markSupported()
markSupported在
Reader
public void mark(int readAheadLimit)
throws IOException
mark在类别
Reader
readAheadLimit - 限制仍然保留标记时可能读取的字符数。
因为流的输入来自字符数组,没有实际的限制;
因此这个论点被忽略。
IOException - 如果发生I / O错误
public void reset()
throws IOException
reset在
Reader
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.