Class ByteArrayInStream

  • All Implemented Interfaces:
    InStream

    public class ByteArrayInStream
    extends java.lang.Object
    implements InStream
    Allows an array of bytes to be used as an InStream. To optimize memory usage, instances can be reused with different byte arrays.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayInStream​(byte[] buffer)
      Creates a new stream based on the given buffer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void read​(byte[] buf)
      Reads up to buf.length bytes from the stream into the given byte buffer.
      void setBytes​(byte[] buffer)
      Sets this stream to read from the given buffer
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteArrayInStream

        public ByteArrayInStream​(byte[] buffer)
        Creates a new stream based on the given buffer.
        Parameters:
        buffer - the bytes to read
    • Method Detail

      • setBytes

        public void setBytes​(byte[] buffer)
        Sets this stream to read from the given buffer
        Parameters:
        buffer - the bytes to read
      • read

        public void read​(byte[] buf)
        Reads up to buf.length bytes from the stream into the given byte buffer.
        Specified by:
        read in interface InStream
        Parameters:
        buf - the buffer to place the read bytes into