Most visited

Recently visited

Added in API level 1

Appendable

public interface Appendable

java.lang.Appendable
Known Indirect Subclasses


可以附加char序列和值的对象。 Appendable接口必须由其实例旨在从Formatter接收格式化输出的任何类实现。

要附加的字符应该是有效的Unicode字符,如Unicode Character Representation中所述 请注意,补充字符可能由多个16位char值组成。

对于多线程访问,追加不一定是安全的。 线程安全是扩展和实现这个接口的类的职责。

由于这个接口可以通过具有不同风格的错误处理的现有类来实现,所以不能保证将错误传播给调用者。

Summary

Public methods

abstract Appendable append(char c)

将指定的字符附加到此 Appendable

abstract Appendable append(CharSequence csq, int start, int end)

将指定字符序列的子序列附加到此 Appendable

abstract Appendable append(CharSequence csq)

将指定的字符序列追加到此 Appendable

Public methods

append

Added in API level 1
Appendable append (char c)

将指定的字符追加到此 Appendable

Parameters
c char: The character to append
Returns
Appendable A reference to this Appendable
Throws
IOException If an I/O error occurs

append

Added in API level 1
Appendable append (CharSequence csq, 
                int start, 
                int end)

将指定字符序列的子序列附加到此 Appendable

形式的这种方法的调用时 out.append(csq, start, end) csq不是 null,行为以完全相同的方式调用

     out.append(csq.subSequence(start, end)) 

Parameters
csq CharSequence: The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
start int: The index of the first character in the subsequence
end int: The index of the character following the last character in the subsequence
Returns
Appendable A reference to this Appendable
Throws
IndexOutOfBoundsException If start or end are negative, start is greater than end, or end is greater than csq.length()
IOException If an I/O error occurs

append

Added in API level 1
Appendable append (CharSequence csq)

将指定的字符序列追加到此 Appendable

根据哪个类实现字符序列csq ,整个序列可能不会被追加。 例如,如果csqCharBuffer则附加子序列由缓冲区的位置和限制定义。

Parameters
csq CharSequence: The character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.
Returns
Appendable A reference to this Appendable
Throws
IOException If an I/O error occurs

Hooray!