public final class ImmutableByteArray extends Object
Wrap a bytearray so it prevents callers from modifying its contents. It does this by making a copy upon initialization, and also makes a copy if the underlying bytes are requested.
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBytes() |
int |
getLength() |
static ImmutableByteArray |
of(byte[] data) |
static ImmutableByteArray |
of(byte[] data,
int start,
int len)
Wrap an immutable byte array over a slice of a bytearray
|
public static ImmutableByteArray of(byte[] data)
data - the byte array to be wrapped.public static ImmutableByteArray of(byte[] data, int start, int len)
data - the byte array to be wrapped.start - the starting index of the slicelen - the length of the slice. start + len must be less than the length of the array.start to start +
lenpublic byte[] getBytes()
public int getLength()