public class MessageWriter
extends java.io.Writer
This class is primarily meant for BaseConnection in contexts where a
standard error stream from a command execution, as well as messages from a
side-band channel, need to be combined together into a buffer to represent
the complete set of messages from a remote repository.
Writes made to the writer are re-encoded as UTF-8 and interleaved into the
buffer that getRawStream() also writes to.
toString() returns all written data, after converting it to a String
under the assumption of UTF-8 encoding.
Internally RawParseUtils.decode(byte[]) is used
by toString() tries to work out a reasonably correct character set
for the raw data.
| Modifier and Type | Field and Description |
|---|---|
private java.io.ByteArrayOutputStream |
buf |
private java.io.OutputStreamWriter |
enc |
| Constructor and Description |
|---|
MessageWriter()
Create an empty writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
java.io.OutputStream |
getRawStream()
Get the underlying byte stream that character writes to this writer drop
into.
|
java.lang.String |
toString() |
void |
write(char[] cbuf,
int off,
int len) |
private final java.io.ByteArrayOutputStream buf
private final java.io.OutputStreamWriter enc
public void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic java.io.OutputStream getRawStream()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object