public class CharDecoderWriter extends Writer
Accepts encoded characters, and writes the raw bytes.
Counter-part to CharEncoderOutputStream
.
This is a push-interface; CharDecoderInputStream
is the equivalent pull-interface.
Can be adapted to accept bytes from a provider (instead of characters)
by wrapping in a OutputStreamWriter
.
Modifier and Type | Field and Description |
---|---|
protected ICharToByteDecoder |
decoder |
protected OutputStream |
outputStream |
protected CharBuffer |
readBuffer |
protected ByteBuffer |
writeBuffer |
Constructor and Description |
---|
CharDecoderWriter(ICharToByteDecoder decoder,
OutputStream outputStream) |
CharDecoderWriter(ICharToByteDecoder decoder,
OutputStream outputStream,
int readBufferSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Convenience method that calls
close(boolean) with true . |
void |
close(boolean closeParent)
Must be called when there is no more data to decode.
|
void |
flush() |
void |
write(char[] cbuf,
int off,
int len) |
protected void |
writeBuffer(CoderResult cr) |
protected ICharToByteDecoder decoder
protected OutputStream outputStream
protected CharBuffer readBuffer
protected ByteBuffer writeBuffer
public CharDecoderWriter(ICharToByteDecoder decoder, OutputStream outputStream)
public CharDecoderWriter(ICharToByteDecoder decoder, OutputStream outputStream, int readBufferSize)
public void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
IOException
protected void writeBuffer(CoderResult cr) throws IOException
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
public void close() throws IOException
Convenience method that calls close(boolean)
with true
.
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
public void close(boolean closeParent) throws IOException
Must be called when there is no more data to decode. This finishes the decoding, writes any finishing bytes required by the decoder, flushes the parent stream, and resets the decoder for possible reuse.
closeParent
- If true
, OutputStream.close()
will be called on the parent.
If false
, only will be called
, allowing for
additional data to be written to the parent before closing it.IOException
Copyright © 2009–2017 Mark A. Ziesemer. All rights reserved.