Class ASMemoryInStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class ASMemoryInStream
    extends SeekableInputStream
    This class binds the SeekableInputStream interface to a memory buffer.
    Author:
    Sergey Shemyakov
    • Constructor Detail

      • ASMemoryInStream

        public ASMemoryInStream​(byte[] buffer)
        Constructor from byte array. Buffer is copied while initializing ASMemoryInStream.
        Parameters:
        buffer - byte array containing data.
      • ASMemoryInStream

        public ASMemoryInStream​(InputStream stream)
                         throws IOException
        Constructor from other stream. It reads stream into byte buffer.
        Parameters:
        stream - is stream to read into byte array.
        Throws:
        IOException
      • ASMemoryInStream

        public ASMemoryInStream​(ASMemoryInStream stream,
                                int offset,
                                int length)
        Constructor that creates substream from other ASMemoryInStream. Note that no buffer copy is performed.
        Parameters:
        stream - is stream, from which substream will be taken.
        offset - is beginning of data to copy.
        length - is length of data to copy.
      • ASMemoryInStream

        public ASMemoryInStream​(byte[] buffer,
                                int bufferSize)
        Constructor from byte array and actual data length. Buffer is copied while initializing ASMemoryInStream.
        Parameters:
        buffer - byte array containing data.
        bufferSize - actual length of data in buffer.
      • ASMemoryInStream

        public ASMemoryInStream​(byte[] buffer,
                                int bufferSize,
                                boolean copyBuffer)
        Constructor from byte array and actual data length. Whether buffer is copied deeply or just reference is copied can be manually set.
        Parameters:
        buffer - byte array containing data.
        bufferSize - actual length of data in buffer.
        copyBuffer - is true if buffer should be copied deeply. Note that if it is set into false then internal buffer can be changed from outside of this class.