java.lang.Object
com.dynatrace.hash4j.internal.ByteArrayUtil
Utility class for byte arrays.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyCharsToByteArray(CharSequence charSequence, int offetCharSequence, byte[] byteArray, int offsetByteArray, int numChars) Copies a given number of characters from aCharSequenceinto a byte array.static chargetChar(byte[] b, int off) Reads acharfrom a byte array with given offset.static intgetInt(byte[] b, int off) Reads anintvalue from a byte array with given offset.static intgetInt(CharSequence charSequence, int off) Reads anintvalue from aCharSequencewith given offset.static longgetLong(byte[] b, int off) Reads alongvalue from a byte array with given offset.static longgetLong(CharSequence charSequence, int off) Reads alongvalue from aCharSequencewith given offset.static shortgetShort(byte[] b, int off) Reads ashortvalue from a byte array with given offset.static voidsetChar(byte[] b, int off, char v) Writes acharto a byte array with given offset.static voidsetInt(byte[] b, int off, int v) Writes anintvalue to a byte array with given offset.static voidsetLong(byte[] b, int off, long v) Writes alongvalue to a byte array with given offset.static voidsetShort(byte[] b, int off, short v) Writes ashortvalue to a byte array with given offset.
-
Method Details
-
getChar
public static char getChar(byte[] b, int off) Reads acharfrom a byte array with given offset.- Parameters:
b- a byte arrayoff- an offset- Returns:
- the read character
-
getShort
public static short getShort(byte[] b, int off) Reads ashortvalue from a byte array with given offset.- Parameters:
b- a byte arrayoff- an offset- Returns:
- the read value
-
getInt
public static int getInt(byte[] b, int off) Reads anintvalue from a byte array with given offset.- Parameters:
b- a byte arrayoff- an offset- Returns:
- the read value
-
getLong
public static long getLong(byte[] b, int off) Reads alongvalue from a byte array with given offset.- Parameters:
b- a byte arrayoff- an offset- Returns:
- the read value
-
setLong
public static void setLong(byte[] b, int off, long v) Writes alongvalue to a byte array with given offset.- Parameters:
b- a byte arrayoff- an offsetv- a value
-
setInt
public static void setInt(byte[] b, int off, int v) Writes anintvalue to a byte array with given offset.- Parameters:
b- a byte arrayoff- an offsetv- a value
-
setShort
public static void setShort(byte[] b, int off, short v) Writes ashortvalue to a byte array with given offset.- Parameters:
b- a byte arrayoff- an offsetv- a value
-
getLong
Reads alongvalue from aCharSequencewith given offset.- Parameters:
charSequence- a char sequenceoff- an offset- Returns:
- the value
-
getInt
Reads anintvalue from aCharSequencewith given offset.- Parameters:
charSequence- a char sequenceoff- an offset- Returns:
- the value
-
setChar
public static void setChar(byte[] b, int off, char v) Writes acharto a byte array with given offset.- Parameters:
b- a byte arrayoff- an offsetv- a character
-
copyCharsToByteArray
public static void copyCharsToByteArray(CharSequence charSequence, int offetCharSequence, byte[] byteArray, int offsetByteArray, int numChars) Copies a given number of characters from aCharSequenceinto a byte array.- Parameters:
charSequence- a char sequenceoffetCharSequence- an offset for the char sequencebyteArray- a byte arrayoffsetByteArray- an offset for the byte arraynumChars- the number of characters to copy
-