public class StringBufferWriter extends Writer
Constructor and Description |
---|
StringBufferWriter(StringBuffer buffer) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the stream, flushing it first.
|
void |
flush()
Flush the stream.
|
StringBuffer |
getBuffer() |
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters.
|
void |
write(int c)
Write a single character.
|
void |
write(String str)
Write a string.
|
public StringBufferWriter(StringBuffer buffer)
public StringBuffer getBuffer()
public void write(int c) throws IOException
Subclasses that intend to support efficient single-character output should override this method.
write
in class Writer
c
- int specifying a character to be written.IOException
- If an I/O error occurspublic void write(String str) throws IOException
write
in class Writer
str
- String to be writtenIOException
- If an I/O error occurspublic void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
cbuf
- Array of charactersoff
- Offset from which to start writing characterslen
- Number of characters to writeIOException
- If an I/O error occurspublic void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
- If an I/O error occurspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
- If an I/O error occurs