Package info.freelibrary.util
Class ByteUtils
- java.lang.Object
-
- info.freelibrary.util.ByteUtils
-
public final class ByteUtils extends Object
A utility class for working with bytes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
asArray(List<Byte> aByteList)
Returns a list of bytes as an array or bytes.static List<Byte>
asList(byte[] aByteArray)
Returns a byte array as a list of bytes.static void
reverse(byte[] aArray)
Reverses the elements ofarray
.static void
reverse(byte[] aByteArray, int aStart, int aEnd)
Reverses the elements of the array.
-
-
-
Method Detail
-
asList
public static List<Byte> asList(byte[] aByteArray)
Returns a byte array as a list of bytes.- Parameters:
aByteArray
- An array of bytes- Returns:
- A list of bytes
-
asArray
public static byte[] asArray(List<Byte> aByteList)
Returns a list of bytes as an array or bytes.- Parameters:
aByteList
- A list of bytes- Returns:
- An array of bytes
-
reverse
public static void reverse(byte[] aArray)
Reverses the elements ofarray
. This is equivalent toCollections.reverse(Bytes.asList(array))
, but is likely to be more efficient.- Parameters:
aArray
- An array of bytes
-
reverse
public static void reverse(byte[] aByteArray, int aStart, int aEnd)
Reverses the elements of the array.- Parameters:
aByteArray
- An array of bytesaStart
- A start positionaEnd
- A end position- Throws:
IndexOutOfBoundsException
- If the start or end are out of range of the array
-
-