public abstract class ArrayUtil
extends java.lang.Object
Arrays class.| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
| Modifier | Constructor and Description |
|---|---|
protected |
ArrayUtil() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
append(byte[] a,
byte[] b,
int capacity)
append the content of two byte arrays up to a certain capacity limit
|
static byte[] |
concat(byte[] a,
byte[] b)
concatenate the content of two byte arrays.
|
static byte[] |
extractBack(byte[] data,
int len) |
static byte[] |
extractFront(byte[] data,
int len) |
static java.lang.String |
formatShortHex(byte[] data) |
static java.lang.String |
formatShortHex(byte[] data,
int off,
int len) |
static java.lang.String |
formatShortHex(java.nio.ByteBuffer data) |
static void |
memsetZero(byte[] buf) |
static void |
memsetZero(java.nio.ByteBuffer buf) |
static <T> void |
pickRandom(T[] source,
T[] destination)
Fills the
destination array with randomly picked values from the source array. |
public static <T> void pickRandom(T[] source,
T[] destination)
destination array with randomly picked values from the source array. No value
will be picked twice.source - The array from which random values must be picked. The content of this array will not be altered.destination - The array which must be filled with random values. Previous values within this array will be
overwritten.java.lang.NullPointerException - If either of the two parameters is null.java.lang.IllegalArgumentException - If the source-array is smaller then the destination
-array.public static byte[] concat(byte[] a,
byte[] b)
a - the first byte array (may be null)b - the second byte array (may be null)a and b, containing a copy of their content.public static byte[] append(byte[] a,
byte[] b,
int capacity)
a - the first byte array (may be null)b - the second byte array (may be null)a and b, containing a copy of their content.
if the combined length exceeds capacity the returned array a will have
a.length == capacity.public static byte[] extractBack(byte[] data,
int len)
public static byte[] extractFront(byte[] data,
int len)
public static java.lang.String formatShortHex(byte[] data)
public static java.lang.String formatShortHex(byte[] data,
int off,
int len)
public static java.lang.String formatShortHex(java.nio.ByteBuffer data)
public static void memsetZero(java.nio.ByteBuffer buf)
public static void memsetZero(byte[] buf)
Copyright © 2012. All Rights Reserved.