-
- 所有已知实现类:
-
BufferedWriter,CharArrayWriter,CharBuffer,FileWriter,FilterWriter,LogStream,OutputStreamWriter,PipedWriter,PrintStream,PrintWriter,StringBuffer,StringBuilder,StringWriter,Writer
public interface Appendable可附加char序列和值的对象。Appendable接口必须由其实例旨在从Formatter接收格式化输出的任何类实现。要附加的字符应为Unicode Character Representation中描述的有效Unicode字符。 请注意,补充字符可以由多个16位
char值组成。对于多线程访问,附加功能不一定是安全的。 线程安全是扩展和实现这个接口的类的责任。
由于此接口可能由具有不同样式的错误处理的现有类实现,因此不能保证将错误传播到调用者。
- 从以下版本开始:
- 1.5
-
-
方法摘要
所有方法 接口方法 抽象方法 Modifier and Type 方法 描述 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"可附加四个字符"null"。 - 结果
-
参考这个
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错误
-
-