com.upokecenter.util.ArrayWriter
com.upokecenter.util.ArrayWriter
public final class ArrayWriter extends Object implements IWriter
An array of bytes that grows as needed.
Constructors
Methods
void Clear()
Offers a fast way to reset the length of the array writer's data to 0.byte[] ToArray()
Generates an array of all bytes written so far to it.void write(byte[] src, int offset, int length)
Writes a series of bytes to the array.void write(int byteValue)
Writes an 8-bit byte to the array.
Method Details
Clear
public void Clear()
Offers a fast way to reset the length of the array writer's data to 0.
ToArray
public byte[] ToArray()
Generates an array of all bytes written so far to it.
Returns:
- A byte array.
write
public void write(int byteValue)
Writes an 8-bit byte to the array.
Specified by:
write
in interfaceIByteWriter
Parameters:
byteValue
- An integer containing the byte to write. Only the lower 8 bits of this value will be used.
write
public void write(byte[] src, int offset, int length)
Writes a series of bytes to the array.
Specified by:
write
in interfaceIWriter
Parameters:
src
- Byte array containing the data to write.offset
- An index starting at 0 showing where the desired portion ofsrc
begins.length
- The number of elements in the desired portion ofsrc
(but not more thansrc
's length).
Throws:
NullPointerException
- The parametersrc
is null.IllegalArgumentException
- Eitheroffset
orlength
is less than 0 or greater thansrc
's length, orsrc
's length minusoffset
is less thanlength
.