public final class ByteUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ByteUtils.ByteConsumer
Used to consume bytes.
|
static interface |
ByteUtils.ByteSupplier
Used to supply bytes.
|
static class |
ByteUtils.InputStreamByteSupplier
ByteUtils.ByteSupplier based on InputStream . |
static class |
ByteUtils.OutputStreamByteConsumer
ByteUtils.ByteConsumer based on OutputStream . |
Modifier and Type | Method and Description |
---|---|
static long |
fromLittleEndian(byte[] bytes)
Reads the given byte array as a little endian long.
|
static long |
fromLittleEndian(byte[] bytes,
int off,
int length)
Reads the given byte array as a little endian long.
|
static long |
fromLittleEndian(ByteUtils.ByteSupplier supplier,
int length)
Reads the given number of bytes from the given supplier as a little endian long.
|
static long |
fromLittleEndian(java.io.DataInput in,
int length)
Reads the given number of bytes from the given input as little endian long.
|
static long |
fromLittleEndian(java.io.InputStream in,
int length)
Reads the given number of bytes from the given stream as a little endian long.
|
static void |
toLittleEndian(byte[] b,
long value,
int off,
int length)
Inserts the given value into the array as a little endian
sequence of the given length starting at the given offset.
|
static void |
toLittleEndian(ByteUtils.ByteConsumer consumer,
long value,
int length)
Provides the given value to the given consumer as a little endian
sequence of the given length.
|
static void |
toLittleEndian(java.io.DataOutput out,
long value,
int length)
Writes the given value to the given stream as a little endian
array of the given length.
|
static void |
toLittleEndian(java.io.OutputStream out,
long value,
int length)
Writes the given value to the given stream as a little endian
array of the given length.
|
public static long fromLittleEndian(byte[] bytes)
bytes
- the byte array to convertpublic static long fromLittleEndian(byte[] bytes, int off, int length)
bytes
- the byte array to convertoff
- the offset into the array that starts the valuelength
- the number of bytes representing the valuejava.lang.IllegalArgumentException
- if len is bigger than eightpublic static long fromLittleEndian(java.io.InputStream in, int length) throws java.io.IOException
in
- the stream to read fromlength
- the number of bytes representing the valuejava.lang.IllegalArgumentException
- if len is bigger than eightjava.io.IOException
- if reading fails or the stream doesn't
contain the given number of bytes anymorepublic static long fromLittleEndian(ByteUtils.ByteSupplier supplier, int length) throws java.io.IOException
Typically used by our InputStreams that need to count the bytes read as well.
supplier
- the supplier for byteslength
- the number of bytes representing the valuejava.lang.IllegalArgumentException
- if len is bigger than eightjava.io.IOException
- if the supplier fails or doesn't supply the
given number of bytes anymorepublic static long fromLittleEndian(java.io.DataInput in, int length) throws java.io.IOException
in
- the input to read fromlength
- the number of bytes representing the valuejava.lang.IllegalArgumentException
- if len is bigger than eightjava.io.IOException
- if reading fails or the stream doesn't
contain the given number of bytes anymorepublic static void toLittleEndian(byte[] b, long value, int off, int length)
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 valuepublic static void toLittleEndian(java.io.OutputStream out, long value, int length) throws java.io.IOException
out
- the stream to write tovalue
- the value to writelength
- the number of bytes to use to represent the valuejava.io.IOException
- if writing failspublic static void toLittleEndian(ByteUtils.ByteConsumer consumer, long value, int length) throws java.io.IOException
consumer
- the consumer to provide the bytes tovalue
- the value to providelength
- the number of bytes to use to represent the valuejava.io.IOException
- if writing failspublic static void toLittleEndian(java.io.DataOutput out, long value, int length) throws java.io.IOException
out
- the output to write tovalue
- the value to writelength
- the number of bytes to use to represent the valuejava.io.IOException
- if writing failsCopyright © 2010 - 2020 Adobe. All Rights Reserved