public final class BytesUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
align(@NonNull byte[] bytes,
int length)
Aligns (expand or narrow) a byte array to a specified length.
|
static char |
asChar(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static double |
asDouble(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static float |
asFloat(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static int |
asInteger(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static long |
asLong(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static short |
asShort(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static short |
asUnsignedByte(byte value)
Converts a value into an unsigned value.
|
static short |
asUnsignedByte(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static long |
asUnsignedInteger(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static long |
asUnsignedInteger(int value)
Converts a value into an unsigned value.
|
static BigInteger |
asUnsignedLong(@NonNull byte[] bytes) |
static BigInteger |
asUnsignedLong(long value) |
static int |
asUnsignedShort(@NonNull byte[] bytes)
Parses a byte array into a value.
|
static int |
asUnsignedShort(short value)
Converts a value into an unsigned value.
|
static byte[] |
concatenate(byte[]... arrays)
Concatenates the several byte arrays into a single one.
|
static char |
readCharacter(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static double |
readDouble(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static float |
readFloat(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static int |
readInteger(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static long |
readLong(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static short |
readShort(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static short |
readUnsignedByte(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static long |
readUnsignedInteger(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static int |
readUnsignedShort(@NonNull byte[] bytes,
int index)
Safe read a value from a byte array.
|
static byte[] |
toBytes(byte value)
Converts a value to a byte array.
|
static byte[] |
toBytes(char value)
Converts a value to a byte array.
|
static byte[] |
toBytes(double value)
Converts a value to a byte array.
|
static byte[] |
toBytes(float value)
Converts a value to a byte array.
|
static byte[] |
toBytes(int value)
Converts a value to a byte array.
|
static byte[] |
toBytes(long value)
Converts a value to a byte array.
|
static byte[] |
toBytes(short value)
Converts a value to a byte array.
|
static char |
unsafeReadCharacter(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static double |
unsafeReadDouble(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static float |
unsafeReadFloat(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static int |
unsafeReadInteger(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static long |
unsafeReadLong(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static short |
unsafeReadShort(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static short |
unsafeReadUnsignedByte(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static long |
unsafeReadUnsignedInteger(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static int |
unsafeReadUnsignedShort(byte[] bytes,
int index)
Unsafe read a value from a byte array.
|
static void |
unsafeWriteByte(int value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
unsafeWriteBytes(byte[] value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
unsafeWriteCharacter(char value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
unsafeWriteDouble(double value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
unsafeWriteFloat(float value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
unsafeWriteInteger(int value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
unsafeWriteLong(long value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
unsafeWriteShort(int value,
byte[] bytes,
int index)
Unsafe write to a byte array.
|
static void |
writeByte(int value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
static void |
writeBytes(byte[] value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
static void |
writeCharacter(char value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
static void |
writeDouble(double value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
static void |
writeFloat(float value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
static void |
writeInteger(int value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
static void |
writeLong(long value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
static void |
writeShort(int value,
@NonNull byte[] bytes,
int index)
Safe write to a byte array.
|
public static void unsafeWriteByte(int value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void unsafeWriteShort(int value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void unsafeWriteInteger(int value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void unsafeWriteLong(long value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void unsafeWriteFloat(float value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void unsafeWriteDouble(double value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void unsafeWriteCharacter(char value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void unsafeWriteBytes(byte[] value,
byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexpublic static void writeByte(int value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static void writeShort(int value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static void writeInteger(int value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static void writeLong(long value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static void writeFloat(float value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static void writeDouble(double value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static void writeCharacter(char value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static void writeBytes(byte[] value,
@NonNull
@NonNull byte[] bytes,
int index)
value - a value to write to the byte arraybytes - the byte array to write toindex - where to start write indexCantWriteToArrayException - in case of discrepancy of the byte array's length and the write indexpublic static byte[] toBytes(byte value)
value - the value to convertpublic static byte[] toBytes(short value)
value - the value to convertpublic static byte[] toBytes(char value)
value - the value to convertpublic static byte[] toBytes(int value)
value - the value to convertpublic static byte[] toBytes(long value)
value - the value to convertpublic static byte[] toBytes(float value)
value - the value to convertpublic static byte[] toBytes(double value)
value - the value to convertpublic static short unsafeReadUnsignedByte(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static short unsafeReadShort(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static int unsafeReadUnsignedShort(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static char unsafeReadCharacter(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static int unsafeReadInteger(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static long unsafeReadUnsignedInteger(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static long unsafeReadLong(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static float unsafeReadFloat(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static double unsafeReadDouble(byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexpublic static short readUnsignedByte(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static short readShort(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static int readUnsignedShort(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static char readCharacter(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static int readInteger(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static long readUnsignedInteger(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static long readLong(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static float readFloat(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static double readDouble(@NonNull
@NonNull byte[] bytes,
int index)
bytes - the byte array to read fromindex - where to start read indexCantReadFromArrayException - in case of discrepancy of the byte array's length and the read indexpublic static short asUnsignedByte(byte value)
value - the signed valuepublic static short asUnsignedByte(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static short asShort(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static int asUnsignedShort(short value)
value - the signed valuepublic static int asUnsignedShort(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static char asChar(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static int asInteger(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static long asUnsignedInteger(int value)
value - the signed valuepublic static long asUnsignedInteger(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static long asLong(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static BigInteger asUnsignedLong(long value)
public static BigInteger asUnsignedLong(@NonNull @NonNull byte[] bytes)
public static float asFloat(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static double asDouble(@NonNull
@NonNull byte[] bytes)
The main difference from the read* methods -
before parsing the byte array the method aligns it an
expected size.
bytes - the byte array for parsingpublic static byte[] concatenate(@NonNull
byte[]... arrays)
arrays - the byte arrays for concatenationpublic static byte[] align(@NonNull
@NonNull byte[] bytes,
int length)
bytes - the byte array for operationlength - the new array's lengthCopyright © 2019–2020 Appulse. All rights reserved.