public final class Bytes extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
Bytes.ByteConsumer
Used to consume bytes.
|
static interface |
Bytes.ByteSupplier
Used to supply bytes.
|
static class |
Bytes.InputStreamByteSupplier
Bytes.ByteSupplier based on InputStream. |
static class |
Bytes.OutputStreamByteConsumer
Bytes.ByteConsumer based on OutputStream. |
| 限定符和类型 | 字段和说明 |
|---|---|
static byte |
CARRIAGE_RETURN |
static byte |
LINE_FEED |
static byte |
SPACE |
static byte |
TAB |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
bigEndianToInt(byte[] bs,
int off) |
static void |
bigEndianToInt(byte[] bs,
int off,
int[] ns) |
static int |
bigEndianToInt(byte b,
byte b2,
byte b3,
byte b4) |
static long |
bigEndianToLong(byte[] bs,
int off) |
static void |
bigEndianToLong(byte[] bs,
int off,
long[] ns) |
static short |
bigEndianToShort(byte[] bs,
int off) |
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(Bytes.ByteSupplier supplier,
int length)
Reads the given number of bytes from the given supplier as a little endian long.
|
static long |
fromLittleEndian(DataInput in,
int length)
Reads the given number of bytes from the given input as little endian long.
|
static long |
fromLittleEndian(InputStream in,
int length)
Reads the given number of bytes from the given stream as a little endian long.
|
static byte[] |
intToBigEndian(int n) |
static byte[] |
intToBigEndian(int[] ns) |
static void |
intToBigEndian(int[] ns,
byte[] bs,
int off) |
static void |
intToBigEndian(int n,
byte[] bs,
int off) |
static byte[] |
intToLittleEndian(int n) |
static byte[] |
intToLittleEndian(int[] ns) |
static void |
intToLittleEndian(int[] ns,
byte[] bs,
int off) |
static void |
intToLittleEndian(int n,
byte[] bs,
int off) |
static boolean |
isLowerCase(byte value) |
static boolean |
isUpperCase(byte value) |
static int |
littleEndianToInt(byte[] bs,
int off) |
static int[] |
littleEndianToInt(byte[] bs,
int off,
int count) |
static void |
littleEndianToInt(byte[] bs,
int off,
int[] ns) |
static void |
littleEndianToInt(byte[] bs,
int bOff,
int[] ns,
int nOff,
int count) |
static long |
littleEndianToLong(byte[] bs,
int off) |
static void |
littleEndianToLong(byte[] bs,
int off,
long[] ns) |
static void |
littleEndianToLong(byte[] bs,
int bsOff,
long[] ns,
int nsOff,
int nsLen) |
static short |
littleEndianToShort(byte[] bs,
int off) |
static long |
littleEndianValue(byte[] bytes,
int offset,
int length) |
static byte[] |
longToBigEndian(long n) |
static byte[] |
longToBigEndian(long[] ns) |
static void |
longToBigEndian(long[] ns,
byte[] bs,
int off) |
static void |
longToBigEndian(long n,
byte[] bs,
int off) |
static void |
longToBigEndian(long value,
byte[] bs,
int off,
int bytes) |
static byte[] |
longToLittleEndian(long n) |
static byte[] |
longToLittleEndian(long[] ns) |
static void |
longToLittleEndian(long[] ns,
byte[] bs,
int off) |
static void |
longToLittleEndian(long[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff) |
static void |
longToLittleEndian(long n,
byte[] bs,
int off) |
static byte[] |
shortToBigEndian(short n) |
static void |
shortToBigEndian(short n,
byte[] bs,
int off) |
static byte[] |
shortToLittleEndian(short n) |
static void |
shortToLittleEndian(short n,
byte[] bs,
int off) |
static byte[] |
toBytes(char value) |
static byte[] |
toBytes(double value) |
static byte[] |
toBytes(float value) |
static byte[] |
toBytes(int value) |
static byte[] |
toBytes(long value) |
static byte[] |
toBytes(short value) |
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(Bytes.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(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(OutputStream out,
long value,
int length)
Writes the given value to the given stream as a little endian
array of the given length.
|
static byte |
toLowerCase(byte c) |
static byte |
toUpperCase(byte b) |
public static final byte SPACE
public static final byte TAB
public static final byte CARRIAGE_RETURN
public static final byte LINE_FEED
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 valueIllegalArgumentException - if len is bigger than eightpublic static long fromLittleEndian(InputStream in, int length) throws IOException
in - the stream to read fromlength - the number of bytes representing the valueIllegalArgumentException - if len is bigger than eightIOException - if reading fails or the stream doesn't
contain the given number of bytes anymorepublic static long fromLittleEndian(Bytes.ByteSupplier supplier, int length) throws 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 valueIllegalArgumentException - if len is bigger than eightIOException - if the supplier fails or doesn't supply the
given number of bytes anymorepublic static long fromLittleEndian(DataInput in, int length) throws IOException
in - the input to read fromlength - the number of bytes representing the valueIllegalArgumentException - if len is bigger than eightIOException - 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 long littleEndianValue(byte[] bytes,
int offset,
int length)
public static void toLittleEndian(OutputStream out, long value, int length) throws IOException
out - the stream to write tovalue - the value to writelength - the number of bytes to use to represent the valueIOException - if writing failspublic static void toLittleEndian(Bytes.ByteConsumer consumer, long value, int length) throws IOException
consumer - the consumer to provide the bytes tovalue - the value to providelength - the number of bytes to use to represent the valueIOException - if writing failspublic static void toLittleEndian(DataOutput out, long value, int length) throws IOException
out - the output to write tovalue - the value to writelength - the number of bytes to use to represent the valueIOException - if writing failspublic static byte toLowerCase(byte c)
public static byte toUpperCase(byte b)
public static boolean isLowerCase(byte value)
public static boolean isUpperCase(byte value)
public static short bigEndianToShort(byte[] bs,
int off)
public static int bigEndianToInt(byte[] bs,
int off)
public static void bigEndianToInt(byte[] bs,
int off,
int[] ns)
public static int bigEndianToInt(byte b,
byte b2,
byte b3,
byte b4)
public static byte[] intToBigEndian(int n)
public static void intToBigEndian(int n,
byte[] bs,
int off)
public static byte[] intToBigEndian(int[] ns)
public static void intToBigEndian(int[] ns,
byte[] bs,
int off)
public static long bigEndianToLong(byte[] bs,
int off)
public static void bigEndianToLong(byte[] bs,
int off,
long[] ns)
public static byte[] longToBigEndian(long n)
public static void longToBigEndian(long n,
byte[] bs,
int off)
public static byte[] longToBigEndian(long[] ns)
public static void longToBigEndian(long[] ns,
byte[] bs,
int off)
public static void longToBigEndian(long value,
byte[] bs,
int off,
int bytes)
value - The numberbs - The target.off - Position in target to start.bytes - number of bytes to write.public static short littleEndianToShort(byte[] bs,
int off)
public static int littleEndianToInt(byte[] bs,
int off)
public static void littleEndianToInt(byte[] bs,
int off,
int[] ns)
public static void littleEndianToInt(byte[] bs,
int bOff,
int[] ns,
int nOff,
int count)
public static int[] littleEndianToInt(byte[] bs,
int off,
int count)
public static byte[] shortToLittleEndian(short n)
public static void shortToLittleEndian(short n,
byte[] bs,
int off)
public static byte[] shortToBigEndian(short n)
public static void shortToBigEndian(short n,
byte[] bs,
int off)
public static byte[] intToLittleEndian(int n)
public static void intToLittleEndian(int n,
byte[] bs,
int off)
public static byte[] intToLittleEndian(int[] ns)
public static void intToLittleEndian(int[] ns,
byte[] bs,
int off)
public static long littleEndianToLong(byte[] bs,
int off)
public static void littleEndianToLong(byte[] bs,
int off,
long[] ns)
public static void littleEndianToLong(byte[] bs,
int bsOff,
long[] ns,
int nsOff,
int nsLen)
public static byte[] longToLittleEndian(long n)
public static void longToLittleEndian(long n,
byte[] bs,
int off)
public static byte[] longToLittleEndian(long[] ns)
public static void longToLittleEndian(long[] ns,
byte[] bs,
int off)
public static void longToLittleEndian(long[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
public static byte[] toBytes(long value)
public static byte[] toBytes(double value)
public static byte[] toBytes(float value)
public static byte[] toBytes(int value)
public static byte[] toBytes(short value)
public static byte[] toBytes(char value)
Copyright © 2021. All rights reserved.