-
public final class ByteUtilsUtility methods for reading and writing bytes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceByteUtils.ByteConsumerUsed to consume bytes.
public interfaceByteUtils.ByteSupplierUsed to supply bytes.
public classByteUtils.InputStreamByteSupplierByteSupplier based on InputStream.
public classByteUtils.OutputStreamByteConsumerByteConsumer based on OutputStream.
-
Field Summary
Fields Modifier and Type Field Description public final static Array<byte>EMPTY_BYTE_ARRAY
-
Method Summary
Modifier and Type Method Description static longfromLittleEndian(Array<byte> bytes)Reads the given byte array as a little endian long. static longfromLittleEndian(Array<byte> bytes, int off, int length)Reads the given byte array as a little endian long. static longfromLittleEndian(ByteUtils.ByteSupplier supplier, int length)Reads the given number of bytes from the given supplier as a little endian long. static longfromLittleEndian(DataInput in, int length)Reads the given number of bytes from the given input as little endian long. static longfromLittleEndian(InputStream in, int length)Reads the given number of bytes from the given stream as a little endian long. static voidtoLittleEndian(Array<byte> b, long value, int off, int length)Inserts the given value into the array as a little endiansequence of the given length starting at the given offset. static voidtoLittleEndian(ByteUtils.ByteConsumer consumer, long value, int length)Provides the given value to the given consumer as a little endiansequence of the given length. static voidtoLittleEndian(DataOutput out, long value, int length)Writes the given value to the given stream as a little endianarray of the given length. static voidtoLittleEndian(OutputStream out, long value, int length)Writes the given value to the given stream as a little endianarray of the given length. -
-
Method Detail
-
fromLittleEndian
static long fromLittleEndian(Array<byte> bytes)
Reads the given byte array as a little endian long.
- Parameters:
bytes- the byte array to convert
-
fromLittleEndian
static long fromLittleEndian(Array<byte> bytes, int off, int length)
Reads the given byte array as a little endian long.
- Parameters:
bytes- the byte array to convertoff- the offset into the array that starts the valuelength- the number of bytes representing the value
-
fromLittleEndian
static long fromLittleEndian(ByteUtils.ByteSupplier supplier, int length)
Reads the given number of bytes from the given supplier as a little endian long.
Typically used by our InputStreams that need to count thebytes read as well.
- Parameters:
supplier- the supplier for byteslength- the number of bytes representing the value
-
fromLittleEndian
static long fromLittleEndian(DataInput in, int length)
Reads the given number of bytes from the given input as little endian long.
- Parameters:
in- the input to read fromlength- the number of bytes representing the value
-
fromLittleEndian
static long fromLittleEndian(InputStream in, int length)
Reads the given number of bytes from the given stream as a little endian long.
- Parameters:
in- the stream to read fromlength- the number of bytes representing the value
-
toLittleEndian
static void toLittleEndian(Array<byte> b, long value, int off, int length)
Inserts the given value into the array as a little endiansequence of the given length starting at the given offset.
- Parameters:
b- the array to write intovalue- the value to insertoff- the offset into the array that receives the first bytelength- the number of bytes to use to represent the value
-
toLittleEndian
static void toLittleEndian(ByteUtils.ByteConsumer consumer, long value, int length)
Provides the given value to the given consumer as a little endiansequence of the given length.
- Parameters:
consumer- the consumer to provide the bytes tovalue- the value to providelength- the number of bytes to use to represent the value
-
toLittleEndian
static void toLittleEndian(DataOutput out, long value, int length)
Writes the given value to the given stream as a little endianarray of the given length.
- Parameters:
out- the output to write tovalue- the value to writelength- the number of bytes to use to represent the value
-
toLittleEndian
static void toLittleEndian(OutputStream out, long value, int length)
Writes the given value to the given stream as a little endianarray of the given length.
- Parameters:
out- the stream to write tovalue- the value to writelength- the number of bytes to use to represent the value
-
-
-
-