Package org.eclipse.jgit.util.io
Class MessageWriter
java.lang.Object
java.io.Writer
org.eclipse.jgit.util.io.MessageWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Combines messages from an OutputStream (hopefully in UTF-8) and a 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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteArrayOutputStream
private final OutputStreamWriter
-
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
buf
-
enc
-
-
Constructor Details
-
MessageWriter
public MessageWriter()Create an empty writer.
-
-
Method Details
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-
getRawStream
Get the underlying byte stream that character writes to this writer drop into.- Returns:
- the underlying byte stream that character writes to this writer drop into. Writes to this stream should should be in UTF-8.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
toString
-