public final class AppendableWriter extends Writer
This class allows any Appendable
to be used as
a writer.
Constructor and Description |
---|
AppendableWriter()
Creates a new appendable writer for which the appendable output
is not set.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and
resets this writer for reuse. |
void |
flush()
Flushes the stream.
|
void |
reset() |
AppendableWriter |
setOutput(Appendable output)
Sets the appendable output being written to.
|
void |
write(char c)
Writes a single character.
|
void |
write(char[] cbuf,
int off,
int len)
Writes a portion of an array of characters.
|
void |
write(CharSequence csq)
Writes the specified character sequence.
|
void |
write(int c)
Writes the 16 low-order bits of the given integer value;
the 16 high-order bits are ignored.
|
void |
write(String str,
int off,
int len)
Writes a portion of a string.
|
public AppendableWriter()
setOutput(Appendable)
public AppendableWriter setOutput(Appendable output)
Writer writer = new AppendableWriter().setOutput(new TextBuilder());
output
- the appendable written to.IllegalStateException
- if this writer is being reused and
it has not been closed
or reset
.public void write(char c) throws IOException
c
- char
the character to be written.IOException
- if an I/O error occurs.public void write(int c) throws IOException
write
in class Writer
c
- the value of the character to be written.IOException
- if an I/O error occurs.public void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
cbuf
- the array of characters.off
- the offset from which to start writing characters.len
- the number of characters to write.IOException
- if an I/O error occurs.public void write(String str, int off, int len) throws IOException
write
in class Writer
str
- a String.off
- the offset from which to start writing characters.len
- the number of characters to write.IOException
- if an I/O error occurspublic void write(CharSequence csq) throws IOException
csq
- the character sequence.IOException
- if an I/O error occurspublic void flush()
public void close()
resets
this writer for reuse.public void reset()
Copyright © 2005-2013 Javolution. All Rights Reserved.