Package com.twelvemonkeys.io.enc
Class DecoderStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.twelvemonkeys.io.enc.DecoderStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class DecoderStream extends java.io.FilterInputStreamAnInputStreamthat provides on-the-fly decoding from an underlying stream.- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/enc/DecoderStream.java#2 $
- See Also:
EncoderStream,Decoder
-
-
Constructor Summary
Constructors Constructor Description DecoderStream(java.io.InputStream stream, Decoder decoder)Creates a new decoder stream and chains it to the input stream specified by thestreamargument.DecoderStream(java.io.InputStream stream, Decoder decoder, int bufferSize)Creates a new decoder stream and chains it to the input stream specified by thestreamargument.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()private intfill()Fills the buffer, by decoding data from the underlying input stream.intread()intread(byte[] bytes, int offset, int length)longskip(long length)
-
-
-
Field Detail
-
buffer
private final java.nio.ByteBuffer buffer
-
decoder
private final Decoder decoder
-
-
Constructor Detail
-
DecoderStream
public DecoderStream(java.io.InputStream stream, Decoder decoder)Creates a new decoder stream and chains it to the input stream specified by thestreamargument. The stream will use a default decode buffer size.- Parameters:
stream- the underlying input stream.decoder- the decoder that will be used to decode the underlying stream- See Also:
FilterInputStream.in
-
DecoderStream
public DecoderStream(java.io.InputStream stream, Decoder decoder, int bufferSize)Creates a new decoder stream and chains it to the input stream specified by thestreamargument.- Parameters:
stream- the underlying input stream.decoder- the decoder that will be used to decode the underlying streambufferSize- the size of the decode buffer- See Also:
FilterInputStream.in
-
-
Method Detail
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] bytes, int offset, int length) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
skip
public long skip(long length) throws java.io.IOException- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
fill
private int fill() throws java.io.IOExceptionFills the buffer, by decoding data from the underlying input stream.- Returns:
- the number of bytes decoded, or
-1if the end of the file is reached - Throws:
java.io.IOException- if an I/O error occurs
-
-