public class CharArrayWriter extends Writer
注:()调用这个类没有影响,而这类方法可以在流有没有产生一个IOException闭叫。
Modifier and Type | Field and Description |
---|---|
protected char[] |
buf
存储数据的缓冲区。
|
protected int |
count
缓冲区中的字符数。
|
Constructor and Description |
---|
CharArrayWriter()
创建一个新的该。
|
CharArrayWriter(int initialSize)
创建具有指定的初始大小的一个新的该。
|
Modifier and Type | Method and Description |
---|---|
CharArrayWriter |
append(char c)
将指定的字符到这个作家。
|
CharArrayWriter |
append(CharSequence csq)
将指定的字符序列,这个作家。
|
CharArrayWriter |
append(CharSequence csq, int start, int end)
添加一个序列指定的字符序列,这个作家。
|
void |
close()
关闭流。
|
void |
flush()
冲洗流。
|
void |
reset()
重置缓冲,这样你可以再次使用它没有抛出已分配的缓冲区。
|
int |
size()
返回缓冲区的当前大小。
|
char[] |
toCharArray()
返回输入数据的副本。
|
String |
toString()
将输入数据转换为字符串。
|
void |
write(char[] c, int off, int len)
将字符写入缓冲区。
|
void |
write(int c)
将一个字符写入缓冲区。
|
void |
write(String str, int off, int len)
写入一个字符串的一部分到缓冲区。
|
void |
writeTo(Writer out)
将缓冲区的内容写入到另一个字符流中。
|
public CharArrayWriter()
public CharArrayWriter(int initialSize)
initialSize
-指定初始缓冲大小的整数。
IllegalArgumentException
-如果initialsize是负的
public void write(char[] c, int off, int len)
public void write(String str, int off, int len)
public void writeTo(Writer out) throws IOException
out
-输出流写入
IOException
如果I/O错误发生。
public CharArrayWriter append(CharSequence csq)
这种形式的out.append(csq)方法调用的行为一样,调用
写出来。(CSQ。tostring())
根据字符序列的csq toString规范,整个序列可能不追加。例如,调用字符缓冲区的toString方法将返回一个序列的内容取决于缓冲区的位置和范围。
append
接口
Appendable
append
方法重写,继承类
Writer
csq
-字符序列添加。如果
csq是
null,然后四个字
"null"附加到这个作家。
public CharArrayWriter append(CharSequence csq, int start, int end)
调用这个方法时,csq形式out.append(csq, start, end)不null,表现在完全相同的方式调用
写出来。(CSQ。子序列(开始、结束)。tostring())
append
接口
Appendable
append
方法重写,继承类
Writer
csq
-字符序列的子序列将追加。如果
csq是
null,那么人物将追加好像
csq包含四个字符
"null"。
start
-子序列中的第一个字符的索引
end
-子序列中的最后一个字符后的字符的索引
IndexOutOfBoundsException
-如果
start或
end是负面的,
start大于
end,或
end大于
csq.length()
public CharArrayWriter append(char c)
这种形式的out.append(c)方法调用的行为一样,调用
外写(c)
append
接口
Appendable
append
方法重写,继承类
Writer
c
- 16位字符追加
public void reset()
public char[] toCharArray()
public int size()
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.