Class DynamicByteArray

java.lang.Object
org.jdrupes.httpcodec.util.DynamicByteArray

public class DynamicByteArray extends Object
A dynamically growing byte array.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DynamicByteArray(int initialSize)
    Creates the array with the given initial size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(byte data)
    Appends the given byte, growing the array if necessary.
    void
    append(byte[] data, int offset, int length)
    Appends the given bytes, growing the array if necessary.
    byte[]
    Returns the internal storage for the bytes.
    void
    Resets the position to 0.
    int
    Returns the current position (number of bytes in the array).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DynamicByteArray

      public DynamicByteArray(int initialSize)
      Creates the array with the given initial size.
      Parameters:
      initialSize - the initial size
  • Method Details

    • append

      public void append(byte data)
      Appends the given byte, growing the array if necessary.
      Parameters:
      data - the byte to append
    • append

      public void append(byte[] data, int offset, int length)
      Appends the given bytes, growing the array if necessary.
      Parameters:
      data - an array of bytes
      offset - the first byte to append
      length - the number of bytes to append
    • position

      public int position()
      Returns the current position (number of bytes in the array).
      Returns:
      the position
    • clear

      public void clear()
      Resets the position to 0.
    • array

      public byte[] array()
      Returns the internal storage for the bytes.
      Returns:
      the storage