Class InputChunked

  • All Implemented Interfaces:
    Pool.Poolable, Closeable, AutoCloseable

    public class InputChunked
    extends Input
    An Input that reads lengths and chunks of data from another OutputStream, allowing chunks to be skipped.
    Author:
    Nathan Sweet
    • Method Detail

      • setInputStream

        public void setInputStream​(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 class Input
        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. The InputStream is set to null.
        Overrides:
        setBuffer in class Input
      • reset

        public void reset()
        Description copied from class: Input
        Sets the position and total to zero.
        Specified by:
        reset in interface Pool.Poolable
        Overrides:
        reset in class Input
      • 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 the InputStream, if set. Can be overridden to fill the bytes from another source.
        Overrides:
        fill in class Input
        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.