Package org.jline.utils
Class WriterOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.jline.utils.WriterOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class WriterOutputStream extends java.io.OutputStream
Redirects anOutputStream
to aWriter
by decoding the data using the specifiedCharset
.Note: This class should only be used if it is necessary to redirect an
OutputStream
to aWriter
for compatibility purposes. It is much more efficient to write to theWriter
directly.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.charset.CharsetDecoder
decoder
private java.nio.ByteBuffer
decoderIn
private java.nio.CharBuffer
decoderOut
private java.io.Writer
out
-
Constructor Summary
Constructors Constructor Description WriterOutputStream(java.io.Writer out, java.nio.charset.Charset charset)
WriterOutputStream(java.io.Writer out, java.nio.charset.CharsetDecoder decoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
private void
flushOutput()
Flush the output.private void
processInput(boolean endOfInput)
Decode the contents of the input ByteBuffer into a CharBuffer.void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
-
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
processInput
private void processInput(boolean endOfInput) throws java.io.IOException
Decode the contents of the input ByteBuffer into a CharBuffer.- Parameters:
endOfInput
- indicates end of input- Throws:
java.io.IOException
- if an I/O error occurs
-
flushOutput
private void flushOutput() throws java.io.IOException
Flush the output.- Throws:
java.io.IOException
- if an I/O error occurs
-
-