Class BinaryBuffer

  • All Implemented Interfaces:
    Serializable

    public class BinaryBuffer
    extends Object
    implements Serializable
    The BinaryBuffer class manages binary data. It provides the capabilities similar to the StringBuffer class when working with binary data (bytes).

    This class is thread-safe.

    Author:
    Marcus Portmann
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      BinaryBuffer​(byte[] data)
      Constructs a new BinaryBuffer and initializes it using the specified binary data.
      BinaryBuffer​(BinaryBuffer data)
      Constructs a new BinaryBuffer and initializes it using the specified binary data.
    • Constructor Detail

      • BinaryBuffer

        public BinaryBuffer​(BinaryBuffer data)
        Constructs a new BinaryBuffer and initializes it using the specified binary data.
        Parameters:
        data - BinaryBuffer instance containing the binary data that will be copied and managed by the BinaryBuffer instance
      • BinaryBuffer

        public BinaryBuffer​(byte[] data)
        Constructs a new BinaryBuffer and initializes it using the specified binary data.
        Parameters:
        data - the binary data that will be copied and managed by the BinaryBuffer instance
    • Method Detail

      • append

        public void append​(BinaryBuffer buffer)
        Append the binary data stored in the specified BinaryBuffer instance to this BinaryBuffer.
        Parameters:
        buffer - the existing BinaryBuffer containing the binary data to append
      • append

        public void append​(byte[] data)
        Append the specified binary data to the binary data already stored in the BinaryBuffer.
        Parameters:
        data - the binary data to append
      • clear

        public void clear()
        Clears the BinaryBuffer.
      • getData

        public byte[] getData()
        Returns the binary data managed by the BinaryBuffer.
        Returns:
        the binary data managed by the BinaryBuffer
      • length

        public int length()
        Returns the amount of binary data managed by the BinaryBuffer.
        Returns:
        the amount of binary data managed by the BinaryBuffer