Package com.esotericsoftware.kryo.io
Class InputChunked
- java.lang.Object
-
- java.io.InputStream
-
- com.esotericsoftware.kryo.io.Input
-
- com.esotericsoftware.kryo.io.InputChunked
-
- All Implemented Interfaces:
Pool.Poolable
,java.io.Closeable
,java.lang.AutoCloseable
public class InputChunked extends Input
AnInput
that reads lengths and chunks of data from another OutputStream, allowing chunks to be skipped.- Author:
- Nathan Sweet
-
-
Field Summary
-
Fields inherited from class com.esotericsoftware.kryo.io.Input
buffer, capacity, chars, inputStream, limit, position, total, varEncoding
-
-
Constructor Summary
Constructors Constructor Description InputChunked()
InputChunked(int bufferSize)
InputChunked(java.io.InputStream inputStream)
InputChunked(java.io.InputStream inputStream, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
fill(byte[] buffer, int offset, int count)
Fills the buffer with more bytes.void
nextChunk()
Advances the stream to the next chunk.void
reset()
Sets the position and total to zero.void
setBuffer(byte[] bytes, int offset, int count)
Sets a new buffer to read from.void
setInputStream(java.io.InputStream inputStream)
Sets an InputStream to read from when data in the buffer is exhausted.-
Methods inherited from class com.esotericsoftware.kryo.io.Input
available, canReadInt, canReadLong, canReadVarInt, canReadVarLong, close, end, getBuffer, getInputStream, getVariableLengthEncoding, limit, optional, position, read, read, read, readBoolean, readBooleans, readByte, readBytes, readBytes, readBytes, readByteUnsigned, readChar, readChars, readDouble, readDoubles, readFloat, readFloats, readInt, readInt, readInts, readInts, readLong, readLong, readLongs, readLongs, readShort, readShorts, readShortUnsigned, readString, readStringBuilder, readVarDouble, readVarFloat, readVarInt, readVarIntFlag, readVarIntFlag, readVarLong, require, setBuffer, setLimit, setPosition, setTotal, setVariableLengthEncoding, skip, skip, total
-
-
-
-
Constructor Detail
-
InputChunked
public InputChunked()
- See Also:
Input()
-
InputChunked
public InputChunked(int bufferSize)
- See Also:
Input(int)
-
InputChunked
public InputChunked(java.io.InputStream inputStream)
- See Also:
Input(InputStream)
-
InputChunked
public InputChunked(java.io.InputStream inputStream, int bufferSize)
- See Also:
Input(InputStream, int)
-
-
Method Detail
-
setInputStream
public void setInputStream(java.io.InputStream inputStream)
Description copied from class:Input
Sets an InputStream to read from when data in the buffer is exhausted. The position, limit, and total are reset, discarding any buffered bytes.- Overrides:
setInputStream
in classInput
- Parameters:
inputStream
- May be null.
-
setBuffer
public void setBuffer(byte[] bytes, int offset, int count)
Description copied from class:Input
Sets a new buffer to read from. The bytes are not copied, the old buffer is discarded and the new buffer used in its place. The position and total are reset. TheInputStream
is set to null.
-
reset
public void reset()
Description copied from class:Input
Sets the position and total to zero.- Specified by:
reset
in interfacePool.Poolable
- Overrides:
reset
in classInput
-
fill
protected int fill(byte[] buffer, int offset, int count) throws KryoException
Description copied from class:Input
Fills the buffer with more bytes. The default implementation reads from theInputStream
, if set. Can be overridden to fill the bytes from another source.- Overrides:
fill
in classInput
- Returns:
- -1 if there are no more bytes.
- Throws:
KryoException
-
nextChunk
public void nextChunk()
Advances the stream to the next chunk. InputChunked will appear to hit the end of the data until this method is called.
-
-