Package org.apache.poi.hssf.util
Class LazilyConcatenatedByteArray
java.lang.Object
org.apache.poi.hssf.util.LazilyConcatenatedByteArray
Utility for delaying the concatenation of multiple byte arrays. Doing this up-front
causes significantly more copying, which for a large number of byte arrays can cost
a large amount of time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the array (sets the concatenated length back to zero.void
concatenate
(byte[] array) Concatenates an array onto the end of our array.byte[]
toArray()
Gets the concatenated contents as a single byte array.
-
Constructor Details
-
LazilyConcatenatedByteArray
public LazilyConcatenatedByteArray()
-
-
Method Details
-
clear
public void clear()Clears the array (sets the concatenated length back to zero. -
concatenate
public void concatenate(byte[] array) Concatenates an array onto the end of our array. This is a relatively fast operation.- Parameters:
array
- the array to concatenate.- Throws:
IllegalArgumentException
- ifarray
isnull
.
-
toArray
public byte[] toArray()Gets the concatenated contents as a single byte array. This is a slower operation, but the concatenated array is stored off as a single array again so that subsequent calls will not perform additional copying.- Returns:
- the byte array. Returns
null
if no data has been placed into it.
-