# Class: com.pnfsoftware.jeb.util.collect.BytePipe

A dynamic byte array \(pipe\). Bytes are written/appended at the end; bytes are read from the beginning. Reading methods raise if the number of requested bytes is more than what is available in the array. 

 This class is **thread\-safe for a single producer thread, single consumer thread.** If there are multiple producers and/or multiple consumers, client code is responsible for making sure that writer threads coordinate among themselves, and that reader threads do the same as well. Ideally \(and most likely\), client code should have a single writer thread, and one reader thread \(same or different as the writer's\).

## Constructor: BytePipe

Description: Create an array whose initial capacity if 4,096 bytes.

## Constructor: BytePipe
- parameter: `initialCapacity`, type: `int`

Description: Create an array with the provided initial capacity.
parameter: initialCapacity: strictly positive number

## Method: append
- parameter: `data`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `length`, type: `int`

Description: Append bytes to this array.
parameter: data: 
parameter: offset: 
parameter: length: 

## Method: append
- parameter: `data`, type: `byte[]`

Description: Append bytes to this array.
parameter: data: 

## Method: append
- parameter: `b`, type: `byte`

Description: Append a single byte to this dynamic array.
parameter: b: 

## Method: append
- parameter: `b`, type: `int`

Description: Append a single byte to this dynamic array.
parameter: b: 

## Method: available
- return type: `int`

Description: Get the number of bytes available for reading.
return: the number of bytes available for reading

## Method: blockUntilAvailable
- parameter: `n`, type: `int`
- parameter: `timeout`, type: `long`
- return type: `int`

Description: Wait until enough data is available for reading.
parameter: n: size in bytes
parameter: timeout: in milliseconds \(0 means infinite\)
return: the amount of bytes in the pipe available for reading

## Method: capacity
- return type: `int`

Description: Get the current capacity of the array. Note: the capacity varies as bytes are written/read to the array.
return: the current capacity in bytes

## Method: get
- parameter: `data`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Get a specified amount of bytes. Throws if not enough bytes are available.
parameter: data: 
parameter: offset: 
parameter: size: 

## Method: get
- parameter: `data`, type: `byte[]`

Description: Get a specified amount of bytes. Throws if not enough bytes are available.
parameter: data: 

## Method: get
- return type: `int`

Description: Retrieve a single byte. Throws if there is nothing available.
return: 

## Method: getAll
- return type: `byte[]`

Description: Read all available bytes.
return: 

## Method: limit
- return type: `int`

Description: Get the number of bytes in the pipe.
return: 

## Method: peek
- parameter: `data`, type: `byte[]`
- parameter: `where`, type: `int`
- parameter: `size`, type: `int`

Description: Peek into this array for a specified amount of data. Throws if not enough bytes are available.
parameter: data: 
parameter: where: 
parameter: size: 

## Method: peek
- parameter: `data`, type: `byte[]`

Description: Peek into this array. Throws if not enough bytes are available.
parameter: data: 

## Method: peek
- return type: `byte`

Description: Peek a single byte within this array. Throws if there a byte is not available.
return: 

## Method: position
- return type: `int`

Description: Get the current position in the pipe.
return: 

## Method: readWait
- parameter: `timeout`, type: `long`
- return type: `int`

Description: Read a single byte of data. This method is blocking.
parameter: timeout: in milliseconds; 0 means infinite
return: \-1 on error \(timeout elapsed and no data is available\)

## Method: reset

Description: Reset this array: the number of bytes available for reading becomes 0.

## Method: skip
- parameter: `n`, type: `int`

Description: Skip bytes. Throws if not enough bytes are available.
parameter: n: 

