Package org.jmrtd.io

Class InputStreamBuffer


  • public class InputStreamBuffer
    extends Object
    Buffers an inputstream (whose length is known in advance) and can supply clients with fresh "copies" of that inputstream served from the buffer. NOTE: the original inputstream should no longer be read from, clients should only read bytes from the sub-inputstreams.
    Author:
    The JMRTD team ([email protected])
    • Constructor Detail

      • InputStreamBuffer

        public InputStreamBuffer​(InputStream inputStream,
                                 int length)
        Creates an input stream buffer.
        Parameters:
        inputStream - the input stream
        length - the length of the input stream
    • Method Detail

      • updateFrom

        public void updateFrom​(InputStreamBuffer other)
        Updates this buffer based on some other buffer.
        Parameters:
        other - the other buffer
      • getInputStream

        public InputStreamBuffer.SubInputStream getInputStream()
        Returns a copy of the input stream positioned at 0.
        Returns:
        a copy of the input stream
      • getPosition

        public int getPosition()
        Returns the current position in the buffer.
        Returns:
        the position in the buffer
      • getBytesBuffered

        public int getBytesBuffered()
        Returns the number of bytes buffered so far.
        Returns:
        the number of bytes buffered so far
      • getLength

        public int getLength()
        Returns the size of the buffer.
        Returns:
        the size of the buffer