public class ByteUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
bytesToInt(byte[] value,
ByteOrder byteOrder)
Convert the given 4-byte array to int.
|
static long |
bytesToLong(byte[] value,
ByteOrder byteOrder)
Convert the given 8-byte array to long.
|
static short |
bytesToShort(byte[] value,
ByteOrder byteOrder)
Convert the given 2-byte array to short.
|
static byte[] |
concat(byte[] first,
byte[] second)
Returns byte-array that has the contents of first and (then) second parameter.
|
static byte[] |
intToBytes(int value,
ByteOrder byteOrder)
Returns byte-array-representation of the given int.
|
static boolean |
isNullOrEmpty(byte[] data)
Returns true if given data is null or it's length is equal to 0, false otherwise.
|
static byte[] |
longToBytes(long value,
ByteOrder byteOrder)
Returns byte-array-representation of the given long.
|
static byte[] |
reverse(byte[] data)
Returns byte-arrary (or null if given null) with reversed (last index is now first etc.)
contents.
|
static byte[] |
shortToBytes(short value,
ByteOrder byteOrder)
Returns byte-array-representation of the given int.
|
static byte[] |
writeInt(int source,
byte[] target,
int index,
ByteOrder byteOrder)
Writes the given int to the given target byte[] starting from the given index.
|
static byte[] |
writeLong(long source,
byte[] target,
int index,
ByteOrder byteOrder)
Writes the given long to the given target byte[] starting from the given index.
|
static byte[] |
writeShort(short source,
byte[] target,
int index,
ByteOrder byteOrder)
Writes the given short to the given target byte[] starting from the given index.
|
public static int bytesToInt(byte[] value,
ByteOrder byteOrder)
public static long bytesToLong(byte[] value,
ByteOrder byteOrder)
public static short bytesToShort(byte[] value,
ByteOrder byteOrder)
public static byte[] concat(byte[] first,
byte[] second)
public static byte[] intToBytes(int value,
ByteOrder byteOrder)
public static boolean isNullOrEmpty(byte[] data)
public static byte[] longToBytes(long value,
ByteOrder byteOrder)
public static byte[] reverse(byte[] data)
public static byte[] shortToBytes(short value,
ByteOrder byteOrder)
public static byte[] writeInt(int source,
byte[] target,
int index,
ByteOrder byteOrder)
public static byte[] writeLong(long source,
byte[] target,
int index,
ByteOrder byteOrder)
public static byte[] writeShort(short source,
byte[] target,
int index,
ByteOrder byteOrder)
Copyright © 2026. All rights reserved.