Appendable
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
BufferedWriter,
CharArrayWriter,
CharBuffer,
FileWriter,
FilterWriter,
OutputStreamWriter,
PipedWriter,
PrintStream,
PrintWriter,
StringBuffer,
StringBuilder,
StringWriter,
Writer
BufferedWriter |
Writes text to a character-output stream, buffering characters so as to
provide for the efficient writing of single characters, arrays, and strings. |
CharArrayWriter |
This class implements a character buffer that can be used as an Writer. |
CharBuffer |
A char buffer. |
FileWriter |
Convenience class for writing character files. |
FilterWriter |
Abstract class for writing filtered character streams. |
OutputStreamWriter |
A class for turning a character stream into a byte stream. |
PipedWriter |
Piped character-output streams. |
PrintStream |
A PrintStream adds functionality to another output stream,
namely the ability to print representations of various data values
conveniently. |
PrintWriter |
Prints formatted representations of objects to a text-output stream. |
StringBuffer |
A thread-safe, mutable sequence of characters. |
StringBuilder |
A mutable sequence of characters. |
StringWriter |
A character stream that collects its output in a string buffer, which can
then be used to construct a string. |
Writer |
Abstract class for writing to character streams. |
|
An object to which char sequences and values can be appended. The
Appendable interface must be implemented by any class whose
instances are intended to receive formatted output from a Formatter
.
The characters to be appended should be valid Unicode characters as
described in Unicode Character
Representation. Note that supplementary characters may be composed of
multiple 16-bit char values.
Appendables are not necessarily safe for multithreaded access. Thread
safety is the responsibility of classes that extend and implement this
interface.
Since this interface may be implemented by existing classes
with different styles of error handling there is no guarantee that
errors will be propagated to the invoker.
Public Methods
public
abstract
Appendable
append
(char c)
Appends the specified character to this Appendable.
Parameters
c |
The character to append |
Returns
- A reference to this Appendable
public
abstract
Appendable
append
(CharSequence csq, int start, int end)
Appends a subsequence of the specified character sequence to this
Appendable.
An invocation of this method of the form out.append(csq, start,
end) when csq is not null, behaves in
exactly the same way as the invocation
out.append(csq.subSequence(start, end))
Parameters
csq |
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 |
The index of the first character in the subsequence |
end |
The index of the character following the last character in the
subsequence |
Returns
- A reference to this Appendable
Appends the specified character sequence to this Appendable.
Depending on which class implements the character sequence
csq, the entire sequence may not be appended. For
instance, if csq is a CharBuffer
then
the subsequence to append is defined by the buffer's position and limit.
Parameters
csq |
The character sequence to append. If csq is
null, then the four characters "null" are
appended to this Appendable. |
Returns
- A reference to this Appendable
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eAppendable\u003c/code\u003e interface defines methods for appending character sequences and values to an object, primarily for receiving formatted output.\u003c/p\u003e\n"],["\u003cp\u003eImplementations of \u003ccode\u003eAppendable\u003c/code\u003e are used by \u003ccode\u003eFormatter\u003c/code\u003e to receive formatted output, and they should handle Unicode characters, including supplementary characters.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003eAppendable\u003c/code\u003e provides methods for appending characters, character sequences, and subsequences, it doesn't guarantee thread safety or consistent error handling across implementations.\u003c/p\u003e\n"],["\u003cp\u003eVarious classes like \u003ccode\u003eBufferedWriter\u003c/code\u003e, \u003ccode\u003eStringBuilder\u003c/code\u003e, and \u003ccode\u003ePrintStream\u003c/code\u003e implement the \u003ccode\u003eAppendable\u003c/code\u003e interface for diverse use cases.\u003c/p\u003e\n"]]],["The `Appendable` interface allows objects to receive formatted output, specifically by appending character sequences or individual characters. Key actions include appending a single character via `append(char c)`, appending a subsequence using `append(CharSequence csq, int start, int end)`, and appending an entire character sequence with `append(CharSequence csq)`. Implementors should handle Unicode characters and be aware that the interface doesn't guarantee thread safety or error propagation. Several subclasses are designed to work with characters and strings, allowing efficient writing, buffering, and manipulation.\n"],null,["public interface **Appendable** \n\n|---|---|---|\n| Known Indirect Subclasses [BufferedWriter](../../../reference/java/io/BufferedWriter.html), [CharArrayWriter](../../../reference/java/io/CharArrayWriter.html), [CharBuffer](../../../reference/java/nio/CharBuffer.html), [FileWriter](../../../reference/java/io/FileWriter.html), [FilterWriter](../../../reference/java/io/FilterWriter.html), [OutputStreamWriter](../../../reference/java/io/OutputStreamWriter.html), [PipedWriter](../../../reference/java/io/PipedWriter.html), [PrintStream](../../../reference/java/io/PrintStream.html), [PrintWriter](../../../reference/java/io/PrintWriter.html), [StringBuffer](../../../reference/java/lang/StringBuffer.html), [StringBuilder](../../../reference/java/lang/StringBuilder.html), [StringWriter](../../../reference/java/io/StringWriter.html), [Writer](../../../reference/java/io/Writer.html) |--------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| | [BufferedWriter](../../../reference/java/io/BufferedWriter.html) | Writes text to a character-output stream, buffering characters so as to provide for the efficient writing of single characters, arrays, and strings. | | [CharArrayWriter](../../../reference/java/io/CharArrayWriter.html) | This class implements a character buffer that can be used as an Writer. | | [CharBuffer](../../../reference/java/nio/CharBuffer.html) | A char buffer. | | [FileWriter](../../../reference/java/io/FileWriter.html) | Convenience class for writing character files. | | [FilterWriter](../../../reference/java/io/FilterWriter.html) | Abstract class for writing filtered character streams. | | [OutputStreamWriter](../../../reference/java/io/OutputStreamWriter.html) | A class for turning a character stream into a byte stream. | | [PipedWriter](../../../reference/java/io/PipedWriter.html) | Piped character-output streams. | | [PrintStream](../../../reference/java/io/PrintStream.html) | A `PrintStream` adds functionality to another output stream, namely the ability to print representations of various data values conveniently. | | [PrintWriter](../../../reference/java/io/PrintWriter.html) | Prints formatted representations of objects to a text-output stream. | | [StringBuffer](../../../reference/java/lang/StringBuffer.html) | A thread-safe, mutable sequence of characters. | | [StringBuilder](../../../reference/java/lang/StringBuilder.html) | A mutable sequence of characters. | | [StringWriter](../../../reference/java/io/StringWriter.html) | A character stream that collects its output in a string buffer, which can then be used to construct a string. | | [Writer](../../../reference/java/io/Writer.html) | Abstract class for writing to character streams. | |||\n\nAn object to which char sequences and values can be appended. The\nAppendable interface must be implemented by any class whose\ninstances are intended to receive formatted output from a [Formatter](../../../reference/java/util/Formatter.html).\n\nThe characters to be appended should be valid Unicode characters as\ndescribed in [Unicode Character\nRepresentation](/j2objc/javadoc/jre/reference/java/lang/Character#unicode). Note that supplementary characters may be composed of\nmultiple 16-bit char values.\n\nAppendables are not necessarily safe for multithreaded access. Thread\nsafety is the responsibility of classes that extend and implement this\ninterface.\n\nSince this interface may be implemented by existing classes\nwith different styles of error handling there is no guarantee that\nerrors will be propagated to the invoker. \n\nPublic Method Summary\n\n|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Appendable](../../../reference/java/lang/Appendable.html) | [append](../../../reference/java/lang/Appendable.html#append(char))(char c) Appends the specified character to this Appendable. |\n| abstract [Appendable](../../../reference/java/lang/Appendable.html) | [append](../../../reference/java/lang/Appendable.html#append(java.lang.CharSequence,%20int,%20int))([CharSequence](../../../reference/java/lang/CharSequence.html) csq, int start, int end) Appends a subsequence of the specified character sequence to this Appendable. |\n| abstract [Appendable](../../../reference/java/lang/Appendable.html) | [append](../../../reference/java/lang/Appendable.html#append(java.lang.CharSequence))([CharSequence](../../../reference/java/lang/CharSequence.html) csq) Appends the specified character sequence to this Appendable. |\n\nPublic Methods \n\npublic abstract [Appendable](../../../reference/java/lang/Appendable.html)\n**append**\n(char c) \nAppends the specified character to this Appendable. \n\nParameters\n\n| c | The character to append |\n|---|-------------------------|\n\nReturns\n\n- A reference to this Appendable \n\nThrows\n\n| [IOException](../../../reference/java/io/IOException.html) | If an I/O error occurs |\n|------------------------------------------------------------|------------------------|\n\npublic abstract [Appendable](../../../reference/java/lang/Appendable.html)\n**append**\n([CharSequence](../../../reference/java/lang/CharSequence.html) csq, int start, int end) \nAppends a subsequence of the specified character sequence to this\nAppendable.\n\nAn invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in\nexactly the same way as the invocation\n\n```\n out.append(csq.subSequence(start, end)) \n```\n\n\u003cbr /\u003e\n\nParameters\n\n| csq | 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\". |\n| start | The index of the first character in the subsequence |\n| end | The index of the character following the last character in the subsequence |\n|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\nReturns\n\n- A reference to this Appendable \n\nThrows\n\n| [IndexOutOfBoundsException](../../../reference/java/lang/IndexOutOfBoundsException.html) | If start or end are negative, start is greater than end, or end is greater than csq.length() |\n| [IOException](../../../reference/java/io/IOException.html) | If an I/O error occurs |\n|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|\n\npublic abstract [Appendable](../../../reference/java/lang/Appendable.html)\n**append**\n([CharSequence](../../../reference/java/lang/CharSequence.html) csq) \nAppends the specified character sequence to this Appendable.\n\nDepending on which class implements the character sequence\ncsq, the entire sequence may not be appended. For\ninstance, if csq is a [CharBuffer](../../../reference/java/nio/CharBuffer.html) then\nthe subsequence to append is defined by the buffer's position and limit. \n\nParameters\n\n| csq | The character sequence to append. If csq is null, then the four characters \"null\" are appended to this Appendable. |\n|-----|--------------------------------------------------------------------------------------------------------------------|\n\nReturns\n\n- A reference to this Appendable \n\nThrows\n\n| [IOException](../../../reference/java/io/IOException.html) | If an I/O error occurs |\n|------------------------------------------------------------|------------------------|"]]