public class ByteArrayUtils extends Object
| Constructor and Description |
|---|
ByteArrayUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
compare(byte[] a1,
byte[] a2)
lexicographic comparison which returns 0 if one of the array is a subarray of the other one
|
static int |
decodeInt(byte[] a,
int offset) |
static int |
decodeShort(byte[] a,
int offset) |
static byte[] |
encodeInt(int x,
byte[] a,
int offset)
write an int into a byte array at offset and returns the array
|
static byte[] |
encodeLong(long x,
byte[] a,
int offset)
write an long into a byte array at offset and returns the array
|
static boolean |
equalsPrefix(byte[] a,
byte[] b,
int n)
Compares the first n bytes of two arrays.
|
static byte[] |
plusOne(byte[] a)
If the array is considered binary representation of an integer, add 1 to the integer and returns the corresponding binary representation.
|
static boolean |
startsWith(byte[] a,
byte[] b)
returns true if a starts with b
|
public static boolean startsWith(byte[] a,
byte[] b)
a - b - NullPointerException - if any of them is nullpublic static boolean equalsPrefix(byte[] a,
byte[] b,
int n)
a - - the first array to compareb - - the second array to comparen - - the number of bytes to compareNullPointerException - if any of them is nullpublic static byte[] plusOne(byte[] a)
a - public static int compare(byte[] a1,
byte[] a2)
a1 - a2 - public static byte[] encodeInt(int x,
byte[] a,
int offset)
public static byte[] encodeLong(long x,
byte[] a,
int offset)
public static int decodeInt(byte[] a,
int offset)
public static int decodeShort(byte[] a,
int offset)
Copyright © 2018 Space Applications Services. All rights reserved.