## net.i2p.client.streaming
Class ByteCollector

    java.lang.Object
      net.i2p.client.streaming.ByteCollector

Deprecated. Only used by deprecated I2PSocketImpl

     class ByteCollector

extends Object

Like a StringBuffer, but for bytes. This class is not internally synchronized, so care should be taken when using in a multithreaded environment.

Field Summary
`(package private) byte[]` `contents` Deprecated.
`(package private) int` `size` Deprecated.

Constructor Summary
`ByteCollector()` Deprecated. New collector with the default initial capacity
`ByteCollector(byte b)` Deprecated. New collector with the specified byte
`ByteCollector(byte[] b)` Deprecated. New collector containing the specified bytes
`ByteCollector(int capacity)` Deprecated. New collector with an initial capacity as specified

Method Summary
`ByteCollector` `append(byte b)` Deprecated. Add a new byte to the collector (extending the buffer if necessary)
`ByteCollector` `append(byte[] b)` Deprecated. Add new bytes to the collector (extending the buffer if necessary)
`ByteCollector` `append(byte[] b, int len)` Deprecated. Add new bytes to the collector (extending the buffer if necessary)
`ByteCollector` `append(byte[] b, int off, int len)` Deprecated. Add new bytes to the collector (extending the buffer if necessary)
`ByteCollector` `append(ByteCollector bc)` Deprecated. Add the contents of the byte collector to the current collector (extending the buffer if necessary)
`void` `clear()` Deprecated. Empty the collector.
`void` `clearAndShorten()` Deprecated. Empty the collector and reduce its capacity.
`boolean` `ensureCapacity(int cap)` Deprecated. Make sure we have sufficient storage space.
`boolean` `equals(Object o)` Deprecated. Compare the collectors.
`int` `getCurrentSize()` Deprecated. How many bytes are available for retrieval?
`int` `hashCode()` Deprecated.
`int` `indexOf(byte b)` Deprecated. Search through the collector for the first occurrence of the specified byte
`int` `indexOf(byte[] ba)` Deprecated. Search through the collector for the first occurrence of the sequence of bytes
`int` `indexOf(ByteCollector bc)` Deprecated. Search through the collector for the first occurrence of the sequence of bytes contained within the specified collector
`boolean` `isEmpty()` Deprecated. Does the collector have meaningful data or is it empty?
`byte` `removeFirst()` Deprecated. Remove the first byte from the collector, shifting its contents accordingly.
`byte[]` `startToByteArray(int maxlen)` Deprecated. Pull off the first $maxlen bytes from the collector, shifting the remaining bytes into the beginning of the collector's array.
`byte[]` `toByteArray()` Deprecated. Copy the contents of the collector into a new array and return it
`String` `toString()` Deprecated. Render the bytes as a string

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### contents

    byte[] contents

  Deprecated.

### size

    int size

  Deprecated.

Constructor Detail

### ByteCollector

    public ByteCollector()

  Deprecated.
  New collector with the default initial capacity

### ByteCollector

    public ByteCollector(int capacity)

  Deprecated.
  New collector with an initial capacity as specified

### ByteCollector

    public ByteCollector(byte[] b)

  Deprecated.
  New collector containing the specified bytes

### ByteCollector

    public ByteCollector(byte b)

  Deprecated.
  New collector with the specified byte

Method Detail

### append

    public ByteCollector append(byte b)

  Deprecated.
  Add a new byte to the collector (extending the buffer if necessary)

  Parameters:
    `b` - byte to add
  Returns:
    this object

### append

    public ByteCollector append(byte[] b)

  Deprecated.
  Add new bytes to the collector (extending the buffer if necessary)

  Parameters:
    `b` - bytes to add
  Returns:
    this object

### append

    public ByteCollector append(byte[] b,
                                int len)

  Deprecated.
  Add new bytes to the collector (extending the buffer if necessary)

  Parameters:
    `b` - byte array to add from
    `len` - number of bytes in the array to add
  Returns:
    this object

### append

    public ByteCollector append(byte[] b,
                                int off,
                                int len)

  Deprecated.
  Add new bytes to the collector (extending the buffer if necessary)

  Parameters:
    `b` - byte array to add from
    `off` - offset into the array to begin adding from
    `len` - number of bytes in the array to add
  Returns:
    this object

### append

    public ByteCollector append(ByteCollector bc)

  Deprecated.
  Add the contents of the byte collector to the current collector (extending the buffer if necessary)

  Parameters:
    `bc` - collector to copy
  Returns:
    this object

### toByteArray

    public byte[] toByteArray()

  Deprecated.
  Copy the contents of the collector into a new array and return it

  Returns:
    new array containing a copy of the current collector's data

### startToByteArray

    public byte[] startToByteArray(int maxlen)

  Deprecated.
  Pull off the first $maxlen bytes from the collector, shifting the remaining bytes into the beginning of the collector's array.

  Parameters:
    `maxlen` - max number of bytes we want to pull from the collector (we will get less if the collector doesnt have that many bytes yet)
  Returns:
    copy of the bytes pulled from the collector

### getCurrentSize

    public int getCurrentSize()

  Deprecated.
  How many bytes are available for retrieval?

  Returns:
    number of bytes

### ensureCapacity

    public boolean ensureCapacity(int cap)

  Deprecated.
  Make sure we have sufficient storage space.

  Parameters:
    `cap` - minimum number of bytes that the buffer should contain
  Returns:
    true if the the collector was expanded to meet the minimum, false if it was already large enough

### isEmpty

    public boolean isEmpty()

  Deprecated.
  Does the collector have meaningful data or is it empty?

  Returns:
    true if it has no data

### indexOf

    public int indexOf(ByteCollector bc)

  Deprecated.
  Search through the collector for the first occurrence of the sequence of bytes contained within the specified collector

  Parameters:
    `bc` - bytes that will be searched for
  Returns:
    index into the current collector, or -1 if it isn't found

### indexOf

    public int indexOf(byte b)

  Deprecated.
  Search through the collector for the first occurrence of the specified byte

  Parameters:
    `b` - byte that will be searched for
  Returns:
    index into the current collector, or -1 if it isn't found

### indexOf

    public int indexOf(byte[] ba)

  Deprecated.
  Search through the collector for the first occurrence of the sequence of bytes

  Parameters:
    `ba` - bytes that will be searched for
  Returns:
    index into the current collector, or -1 if it isn't found

### clear

    public void clear()

  Deprecated.
  Empty the collector. This does not affect its capacity.

### clearAndShorten

    public void clearAndShorten()

  Deprecated.
  Empty the collector and reduce its capacity.

### toString

    public String toString()

  Deprecated.
  Render the bytes as a string

  Overrides:
    `toString` in class `Object`
  Returns:
    the, uh, string

### hashCode

    public int hashCode()

  Deprecated.
  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object o)

  Deprecated.
  Compare the collectors.

  Overrides:
    `equals` in class `Object`
  Returns:
    true if and only if both are the same size and the byte arrays they contain are equal.

### removeFirst

    public byte removeFirst()
                     throws IllegalArgumentException

  Deprecated.
  Remove the first byte from the collector, shifting its contents accordingly.

  Returns:
    byte removed
  Throws:
    `IllegalArgumentException` - if the collector is empty