public final class ByteArray extends Object
Modifier and Type | Method and Description |
---|---|
static String |
bytesToHRString(byte[] bytes)
Decodes bytes to human readable UTF-8 string.
|
static int |
bytesToInt(byte[] bytes)
Converts byte array to Integer.
|
static long |
bytesToLong(byte[] bytes)
Converts byte array to long.
|
static byte |
copyBitsRange(byte src,
int fromBit,
int length)
Copies range of bits from passed byte and align to right.
|
static byte[] |
cutBytes(byte[] bytes,
int count)
Cuts 'count' number of bytes from the beginning of given byte array.
|
static String |
encodeBase64(io.netty.buffer.ByteBuf buffer)
Encode input ByteBuf with Base64 to string format.
|
static byte[] |
fileToBytes(String name)
Parses file to array of bytes
|
static byte[] |
getAllBytes(io.netty.buffer.ByteBuf buffer)
Helper method missing from netty ByteBuf methods.
|
static byte[] |
getBytes(io.netty.buffer.ByteBuf buffer,
int length)
Helper method missing from netty ByteBuf methods.
|
static byte[] |
readAllBytes(io.netty.buffer.ByteBuf buffer)
Helper method missing from netty ByteBuf methods.
|
static byte[] |
readBytes(io.netty.buffer.ByteBuf buffer,
int length)
Helper method missing from netty ByteBuf methods.
|
static byte[] |
subByte(byte[] bytes,
int startIndex,
int length)
Returns a new byte array from given byte array, starting at start index with the size of the length parameter.
|
public static byte[] readBytes(io.netty.buffer.ByteBuf buffer, int length)
buffer
- ByteBuf from which the bytes are going to be takenlength
- length of the returned byte arraypublic static byte[] readAllBytes(io.netty.buffer.ByteBuf buffer)
buffer
- byteBuf from which the bytes are going to be takenpublic static byte[] getBytes(io.netty.buffer.ByteBuf buffer, int length)
buffer
- ByteBuf from which the bytes are going to be takenlength
- length of the returned byte arraypublic static byte[] getAllBytes(io.netty.buffer.ByteBuf buffer)
buffer
- byteBuf from which the bytes are going to be takenpublic static byte[] subByte(byte[] bytes, int startIndex, int length)
bytes
- original byte arraystartIndex
- beginning index, inclusivelength
- how many bytes should be in the sub-arraypublic static int bytesToInt(byte[] bytes)
bytes
- array to be converted to intpublic static long bytesToLong(byte[] bytes)
bytes
- array to be converted to longpublic static byte[] cutBytes(byte[] bytes, int count)
bytes
- array to be cut, cannot be nullcount
- how many bytes needed to be cut, needs to be greater than 0public static byte[] fileToBytes(String name) throws IOException
name
- path to file to by parsedIOException
public static byte copyBitsRange(byte src, int fromBit, int length)
src
- source byte to copy fromfromBit
- bit from which will copy (inclusive) - numbered from 0length
- of bits to by copied, valid values are 1 through 8public static String bytesToHRString(byte[] bytes)
bytes
- bytes to be decoded to stringpublic static String encodeBase64(io.netty.buffer.ByteBuf buffer)
buffer
- Input ByteBufCopyright © 2018 OpenDaylight. All rights reserved.