public class ByteUtilities
extends java.lang.Object
Constructor and Description |
---|
ByteUtilities() |
Modifier and Type | Method and Description |
---|---|
static int |
byteToShortUnsigned(byte b) |
static int |
compareInt(int i1,
int i2) |
static int |
compareUnsigned(short b1,
short b2)
Compares two unsigned shorts.
|
static byte[] |
getBit(boolean value,
int length,
java.nio.ByteOrder order)
Converts a boolean into a byte array of length length.
|
static java.lang.Boolean |
getBit(byte[] buf,
int offset,
int length,
int bit,
java.nio.ByteOrder order)
Returns bit bit from a byte array of length length.
|
static short |
getBitPosition(long mask)
Gets the first bit's position that is high from the mask.
|
static float |
getFloat4(byte[] buf,
int offset,
java.nio.ByteOrder order)
Parses 4 bytes from a byte array, starting at the offset, into a float.
|
static byte[] |
getFloat4(float value,
java.nio.ByteOrder order)
Converts a float into a byte array of length 4.
|
static double |
getFloat8(byte[] buf,
int offset,
java.nio.ByteOrder order)
Parses 8 bytes from a byte array, starting at the offset, into a double.
|
static byte[] |
getFloat8(double value,
java.nio.ByteOrder order)
Converts a double into a byte array of length 8.
|
static short |
getInt1(byte[] buf,
int offset)
Parses 1 byte from a byte array, starting at the offset, into a short.
|
static byte[] |
getInt1(int value)
Converts an integer into a byte array of length 1.
|
static short |
getInt2(byte[] buf,
int offset,
java.nio.ByteOrder order)
Parses 2 bytes from a byte array, starting at the offset, into a short.
|
static byte[] |
getInt2(int value,
java.nio.ByteOrder order)
Converts an integer into a byte array of length 2.
|
static int |
getInt4(byte[] buf,
int offset,
java.nio.ByteOrder order)
Parses 4 bytes from a byte array, starting at the offset, into an
integer.
|
static byte[] |
getInt4(int value,
java.nio.ByteOrder order)
Converts an integer into a byte array of length 4.
|
static long |
getInt8(byte[] buf,
int offset,
java.nio.ByteOrder order)
Parses 8 bytes from a byte array, starting at the offset, into a long.
|
static byte[] |
getInt8(long value,
java.nio.ByteOrder order)
Converts an long into a byte array of length 8.
|
static java.lang.String |
getString(byte[] buf,
int offset,
int length,
java.nio.ByteOrder order)
Parses length bytes from a byte array, starting at the offset, into a
string.
|
static byte[] |
getString(java.lang.String value,
int length,
int offset,
java.nio.ByteOrder order)
Converts a string into a byte array of length length.
|
static java.lang.String |
toAsciiString(byte[] buf)
Converts a byte array into an ASCII string.
|
static java.lang.String |
toString(byte buf)
Converts a byte to a hex string
|
static java.lang.String |
toString(byte[] buf)
Converts a byte array into a hex string
|
static java.lang.String |
toString(java.nio.ByteBuffer... bufs)
Converts multiple byte arrays into a hex string
|
public static short getInt1(byte[] buf, int offset)
public static byte[] getInt1(int value)
public static short getInt2(byte[] buf, int offset, java.nio.ByteOrder order)
public static byte[] getInt2(int value, java.nio.ByteOrder order)
public static int getInt4(byte[] buf, int offset, java.nio.ByteOrder order)
public static byte[] getInt4(int value, java.nio.ByteOrder order)
public static long getInt8(byte[] buf, int offset, java.nio.ByteOrder order)
public static byte[] getInt8(long value, java.nio.ByteOrder order)
public static float getFloat4(byte[] buf, int offset, java.nio.ByteOrder order)
public static byte[] getFloat4(float value, java.nio.ByteOrder order)
public static double getFloat8(byte[] buf, int offset, java.nio.ByteOrder order)
public static byte[] getFloat8(double value, java.nio.ByteOrder order)
public static java.lang.String getString(byte[] buf, int offset, int length, java.nio.ByteOrder order)
public static byte[] getString(java.lang.String value, int length, int offset, java.nio.ByteOrder order)
public static java.lang.Boolean getBit(byte[] buf, int offset, int length, int bit, java.nio.ByteOrder order)
public static byte[] getBit(boolean value, int length, java.nio.ByteOrder order)
public static short getBitPosition(long mask)
public static java.lang.String toString(byte buf)
public static java.lang.String toString(byte[] buf)
public static java.lang.String toAsciiString(byte[] buf)
public static java.lang.String toString(java.nio.ByteBuffer... bufs)
public static int compareUnsigned(short b1, short b2)
public static int compareInt(int i1, int i2)
public static int byteToShortUnsigned(byte b)