public class StringReader extends Reader
Constructor and Description |
---|
StringReader(String s)
创建一个新的字符串阅读器。
|
Modifier and Type | Method and Description |
---|---|
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 ns)
跳过指定数目的字符流中。
|
public StringReader(String s)
s
字符串提供字符流。
public int read() throws IOException
read
方法重写,继承类
Reader
IOException
如果I/O错误发生
public int read(char[] cbuf, int off, int len) throws IOException
read
方法重写,继承类
Reader
cbuf
-目的缓冲区
off
偏移,开始书写汉字
len
-最大字符数读
IOException
如果I/O错误发生
public long skip(long ns) throws IOException
的ns
参数可能是负的,即使Reader
skip
的父类方法抛出例外。ns
负值的原因跳过向后流。负返回值指示跳向后退。它是不可能跳过过去的字符串开头的。
如果整个字符串已被读取或跳过,那么这个方法没有效果,并且总是返回0。
skip
方法重写,继承类
Reader
ns
-字符数跳过
IOException
如果I/O错误发生
public boolean ready() throws IOException
ready
方法重写,继承类
Reader
IOException
如果流关闭
public boolean markSupported()
markSupported
方法重写,继承类
Reader
public void mark(int readAheadLimit) throws IOException
mark
方法重写,继承类
Reader
readAheadLimit
的字符数限制,可同时仍保留了马克读。因为流的输入来自一个字符串,所以没有实际的限制,所以这个参数不能是否定的,但否则将被忽略。
readAheadLimit < 0
IllegalArgumentException
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.