Package org.jdrupes.httpcodec.util
Class DynamicByteArray
java.lang.Object
org.jdrupes.httpcodec.util.DynamicByteArray
A dynamically growing byte array.
-
Constructor Summary
ConstructorDescriptionDynamicByteArray
(int initialSize) Creates the array with the given initial size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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[]
array()
Returns the internal storage for the bytes.void
clear()
Resets the position to 0.int
position()
Returns the current position (number of bytes in the array).
-
Constructor Details
-
DynamicByteArray
Creates the array with the given initial size.- Parameters:
initialSize
- the initial size
-
-
Method Details
-
append
Appends the given byte, growing the array if necessary.- Parameters:
data
- the byte to append
-
append
Appends the given bytes, growing the array if necessary.- Parameters:
data
- an array of bytesoffset
- the first byte to appendlength
- the number of bytes to append
-
position
Returns the current position (number of bytes in the array).- Returns:
- the position
-
clear
Resets the position to 0. -
array
Returns the internal storage for the bytes.- Returns:
- the storage
-