Package com.twelvemonkeys.io.enc
Class EncoderStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.twelvemonkeys.io.enc.EncoderStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public final class EncoderStream extends java.io.FilterOutputStreamAnOutputStreamthat provides on-the-fly encoding to an underlying stream.- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/enc/EncoderStream.java#2 $
- See Also:
DecoderStream,Encoder
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBufferbufferprivate Encoderencoderprivate booleanflushOnWrite
-
Constructor Summary
Constructors Constructor Description EncoderStream(java.io.OutputStream stream, Encoder encoder)Creates an output stream filter built on top of the specified underlying output stream.EncoderStream(java.io.OutputStream stream, Encoder encoder, boolean flushOnWrite)Creates an output stream filter built on top of the specified underlying output stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private voidencodeBuffer()voidflush()voidwrite(byte[] bytes)voidwrite(byte[] values, int offset, int length)voidwrite(int value)
-
-
-
Field Detail
-
encoder
private final Encoder encoder
-
flushOnWrite
private final boolean flushOnWrite
-
buffer
private final java.nio.ByteBuffer buffer
-
-
Constructor Detail
-
EncoderStream
public EncoderStream(java.io.OutputStream stream, Encoder encoder)Creates an output stream filter built on top of the specified underlying output stream.- Parameters:
stream- the underlying output streamencoder- the encoder to use
-
EncoderStream
public EncoderStream(java.io.OutputStream stream, Encoder encoder, boolean flushOnWrite)Creates an output stream filter built on top of the specified underlying output stream.- Parameters:
stream- the underlying output streamencoder- the encoder to useflushOnWrite- iftrue, calls to the byte-arraywritemethods will automatically flush the buffer.
-
-
Method Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
encodeBuffer
private void encodeBuffer() throws java.io.IOException- Throws:
java.io.IOException
-
write
public void write(byte[] bytes) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] values, int offset, int length) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(int value) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
-