Class WriterOutputStream

java.lang.Object
java.io.OutputStream
org.jline.utils.WriterOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class WriterOutputStream extends OutputStream
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.