T
- The type of the Appendable
wrapped by this AppendableWriter.public class AppendableWriter<T extends Appendable> extends Writer
Appendable
Object.
For example, can be used with a StringBuilder
or StringBuffer
.
Appendable
Constructor and Description |
---|
AppendableWriter(T appendable)
Constructs a new instance with the specified appendable.
|
Modifier and Type | Method and Description |
---|---|
Writer |
append(char c)
Appends the specified character to the underlying appendable.
|
Writer |
append(CharSequence csq)
Appends the specified character sequence to the underlying appendable.
|
Writer |
append(CharSequence csq,
int start,
int end)
Appends a subsequence of the specified character sequence to the underlying appendable.
|
void |
close()
Closes the stream.
|
void |
flush()
Flushes the stream.
|
T |
getAppendable()
Return the target appendable.
|
void |
write(char[] cbuf,
int off,
int len)
Writes a portion of an array of characters to the underlying appendable.
|
void |
write(int c)
Writes a character to the underlying appendable.
|
void |
write(String str,
int off,
int len)
Writes a portion of a String to the underlying appendable.
|
public AppendableWriter(T appendable)
appendable
- the appendable to write topublic Writer append(char c) throws IOException
append
in interface Appendable
append
in class Writer
c
- the character to appendIOException
- upon errorpublic Writer append(CharSequence csq) throws IOException
append
in interface Appendable
append
in class Writer
csq
- the character sequence to appendIOException
- upon errorpublic Writer append(CharSequence csq, int start, int end) throws IOException
append
in interface Appendable
append
in class Writer
csq
- the character sequence from which a subsequence will be appendedstart
- the index of the first character in the subsequenceend
- the index of the character following the last character in the subsequenceIOException
- upon errorpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
- upon errorpublic void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
- upon errorpublic T getAppendable()
public void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
cbuf
- an array with the characters to writeoff
- offset from which to start writing characterslen
- number of characters to writeIOException
- upon errorpublic void write(int c) throws IOException
write
in class Writer
c
- the character to writeIOException
- upon errorpublic void write(String str, int off, int len) throws IOException
write
in class Writer
str
- a stringoff
- offset from which to start writing characterslen
- number of characters to writeIOException
- upon errorCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.