Package org.jline.utils
Class WriterOutputStream
java.lang.Object
java.io.OutputStream
org.jline.utils.WriterOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An OutputStream implementation that writes to a Writer, bridging byte and character streams.
The WriterOutputStream class provides an OutputStream implementation that redirects its output to a Writer by decoding the bytes using a specified character encoding. This allows code that expects to write to an OutputStream to work with a Writer destination instead.
This class handles the complexities of character encoding conversion, including:
- Proper handling of multi-byte character encodings
- Buffering of partial character sequences
- Configurable behavior for malformed input and unmappable characters
This class is particularly useful in JLine for bridging between byte-oriented and character-oriented I/O in terminal handling, especially when dealing with legacy APIs that expect byte streams.
Note: This class should only be used if it is necessary to
redirect an OutputStream to a Writer for compatibility
purposes. It is much more efficient to write to the Writer
directly.
-
Constructor Summary
ConstructorsConstructorDescriptionWriterOutputStream(Writer out, Charset charset) WriterOutputStream(Writer out, CharsetDecoder decoder) -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
WriterOutputStream
-
WriterOutputStream
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-