Class FastByteArrayOutputStream

    • Field Detail

      • DEFAULT_INITIAL_CAPACITY

        public static final int DEFAULT_INITIAL_CAPACITY
        The array backing the output stream.
        See Also:
        Constant Field Values
      • array

        public byte[] array
        The array backing the output stream.
      • length

        public int length
        The number of valid bytes in array.
    • Constructor Detail

      • FastByteArrayOutputStream

        public FastByteArrayOutputStream()
        Creates a new array output stream with an initial capacity of DEFAULT_INITIAL_CAPACITY bytes.
      • FastByteArrayOutputStream

        public FastByteArrayOutputStream​(int initialCapacity)
        Creates a new array output stream with a given initial capacity.
        Parameters:
        initialCapacity - the initial length of the backing array.
      • FastByteArrayOutputStream

        public FastByteArrayOutputStream​(byte[] a)
        Creates a new array output stream wrapping a given byte array.
        Parameters:
        a - the byte array to wrap.
    • Method Detail

      • reset

        public void reset()
        Marks this array output stream as empty.
      • trim

        public void trim()
        Ensures that the length of the backing array is equal to length.
      • position

        public void position​(long newPosition)
        Description copied from interface: RepositionableStream
        Sets the current stream position.
        Specified by:
        position in interface RepositionableStream
        Parameters:
        newPosition - the new stream position.
      • length

        public long length()
                    throws IOException
        Description copied from interface: MeasurableStream
        Returns the overall length of this stream (optional operation). In most cases, this will require the stream to perform some extra action, possibly changing the state of the input stream itself (typically, reading all the bytes up to the end, or flushing on output stream). Implementing classes should always document what state will the input stream be in after calling this method, and which kind of exception could be thrown.
        Specified by:
        length in interface MeasurableStream
        Throws:
        IOException