Class BlockedByteArrayInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    class BlockedByteArrayInputStream
    extends java.io.InputStream
    An input stream reading from a blocked byte array.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long pos
      The current position of the stream.
      private BlockedByteArray src
      The underlying source.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the stream.
      (package private) long getPosition()
      Returns the current position.
      int read()
      Reads a single byte.
      int read​(byte[] buf, int offset, int len)
      Reads up to len bytes.
      (package private) void setPosition​(long newPos)
      Sets the position.
      • Methods inherited from class java.io.InputStream

        available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • src

        private BlockedByteArray src
        The underlying source. Set to null when closed.
      • pos

        private long pos
        The current position of the stream.
    • Constructor Detail

      • BlockedByteArrayInputStream

        public BlockedByteArrayInputStream​(BlockedByteArray src,
                                           long pos)
        Creates a new input stream reading from a blocked byte array.
        Parameters:
        src - the source blocked byte array
        pos - the initial position to start reading from
    • Method Detail

      • setPosition

        void setPosition​(long newPos)
        Sets the position.
        Parameters:
        newPos - the new byte position
      • getPosition

        long getPosition()
        Returns the current position.
        Returns:
        The current byte position.
      • read

        public int read()
        Reads a single byte.
        Specified by:
        read in class java.io.InputStream
        Returns:
        A byte.
      • read

        public int read​(byte[] buf,
                        int offset,
                        int len)
        Reads up to len bytes.
        Overrides:
        read in class java.io.InputStream
        Parameters:
        buf - destination buffer
        offset - offset into the destination buffer
        len - number of bytes to read
        Returns:
        The number of bytes read.
      • close

        public void close()
        Closes the stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream