-
- 所有已知实现类:
-
BufferedWriter,CharArrayWriter,CharBuffer,FileWriter,FilterWriter,LogStream,OutputStreamWriter,PipedWriter,PrintStream,PrintWriter,StringBuffer,StringBuilder,StringWriter,Writer
public interface Appendable可以追加char序列和值的对象。Appendable接口必须由其实例用于接收来自Formatter的格式化输出的任何类实现。要附加的字符应该是有效的Unicode字符,如Unicode Character Representation中所述 。 请注意,补充字符可能由多个16位
char值组成。对于多线程访问,可附加项不一定安全。 线程安全是扩展和实现此接口的类的责任。
由于该接口可以由具有不同错误处理样式的现有类实现,因此不能保证错误将传播给调用者。
- 从以下版本开始:
- 1.5
-
-
方法摘要
所有方法 实例方法 抽象方法 变量和类型 方法 描述 Appendableappend(char c)将指定的字符追加到此Appendable。Appendableappend(CharSequence csq)将指定的字符序列追加到此Appendable。Appendableappend(CharSequence csq, int start, int end)将指定字符序列的子序列追加到此Appendable。
-
-
-
方法详细信息
-
append
Appendable append(CharSequence csq) throws IOException
将指定的字符序列追加到此Appendable。根据哪个类实现字符序列
csq,可能不会追加整个序列。 例如,如果csq是CharBuffer,则追加的子序列由缓冲区的位置和限制定义。- 参数
-
csq- 要追加的字符序列。 如果csq是null,则四个字符"null"将附加到此Appendable。 - 结果
-
对此
Appendable的引用 - 异常
-
IOException- 如果发生I / O错误
-
append
Appendable append(CharSequence csq, int start, int end) throws IOException
将指定字符序列的子序列追加到此Appendable。形式的这种方法的调用
out.append(csq, start, end)时csq不是null,行为以完全相同的方式调用out.append(csq.subSequence(start, end))- 参数
-
csq- 将附加子序列的字符序列。 如果csq是null,则将附加字符,就像csq包含四个字符"null"。 -
start- 子序列中第一个字符的索引 -
end- 子序列中最后一个字符后面的字符的索引 - 结果
-
对此
Appendable的引用 - 异常
-
IndexOutOfBoundsException- 如果start或end为负数,则start大于end,或end大于csq.length() -
IOException- 如果发生I / O错误
-
append
Appendable append(char c) throws IOException
将指定的字符追加到此Appendable。- 参数
-
c- 要追加的角色 - 结果
-
对此
Appendable的引用 - 异常
-
IOException- 如果发生I / O错误
-
-