Package java.lang
Interface Appendable
-
- All Known Implementing Classes:
BufferedWriter,CharArrayWriter,CharBuffer,FileWriter,FilterWriter,Normalizer2Impl.ReorderingBuffer,OutputStreamWriter,PemWriter,PipedWriter,PrintStream,PrintWriter,StringBuffer,StringBuilder,StringWriter,Writer
public interface AppendableDeclares methods to append characters or character sequences. Any class that implements this interface can receive data formatted by aFormatter. The appended character or character sequence should be valid according to the rules described inUnicode Character Representation.Appendableitself does not guarantee thread safety. This responsibility is up to the implementing class.Implementing classes can choose different exception handling mechanism. They can choose to throw exceptions other than
IOExceptionor they do not throw any exceptions at all and use error codes instead.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Appendableappend(char c)Appends the specified character.Appendableappend(CharSequence csq)Appends the character sequencecsq.Appendableappend(CharSequence csq, int start, int end)Appends a subsequence ofcsq.
-
-
-
Method Detail
-
append
Appendable append(char c) throws IOException
Appends the specified character.- Parameters:
c- the character to append.- Returns:
- this
Appendable. - Throws:
IOException- if an I/O error occurs.
-
append
Appendable append(CharSequence csq) throws IOException
Appends the character sequencecsq. Implementation classes may not append the whole sequence, for example if the target is a buffer with limited size.If
csqisnull, the characters "null" are appended.- Parameters:
csq- the character sequence to append.- Returns:
- this
Appendable. - Throws:
IOException- if an I/O error occurs.
-
append
Appendable append(CharSequence csq, int start, int end) throws IOException
Appends a subsequence ofcsq.If
csqis notnullthen calling this method is equivalent to callingappend(csq.subSequence(start, end)).If
csqisnull, the characters "null" are appended.- Parameters:
csq- the character sequence to append.start- the first index of the subsequence ofcsqthat is appended.end- the last index of the subsequence ofcsqthat is appended.- Returns:
- this
Appendable. - Throws:
IndexOutOfBoundsException- ifstart < 0,end < 0,start > endorendis greater than the length ofcsq.IOException- if an I/O error occurs.
-
-