public final class Bytes extends Object
转hex:new BigInteger(1, bytes).toString(16); Padding4位:(4 - (length & 0x03)) & 0x03 左移<<: 该数对应的二进制码整体左移,左边超出的部分舍弃,右边补0 右移>>: 该数对应的二进制码整体右移,左边部分以原有标志位填充,右边超出的部分舍弃 无符号右移>>>: 该数对应的二进制码整体右移,左边部分以0填充,右边超出的部分舍弃
| 构造器和说明 |
|---|
Bytes() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
concat(byte[] first,
byte[]... rest)
merge byte arrays
|
static long |
crc32(byte[] bytes) |
static void |
headCopy(byte[] src,
byte[] dest)
copy src to dest
从首部开始拷贝src到dest:
若src数据不足则在dest后面补tailing
若src数据有多则舍去src后面的数据
|
static void |
headCopy(byte[] src,
int srcFrom,
int srcLen,
byte[] dest,
int destFrom,
int destLen,
byte tailing) |
static byte[] |
hexDecode(String hex)
decode the hex string to byte array
|
static String |
hexDump(byte[] data) |
static String |
hexDump(byte[] data,
int chunk,
int block)
Dump byte array, like as these
HexDump.dump(byte[], long, java.io.OutputStream, int),
CharacterEncoder.encode(byte[], java.io.OutputStream); |
static String |
hexEncode(byte[] bytes) |
static String |
hexEncode(byte[] bytes,
boolean lowercase)
encode the byte array the hex string
|
static String |
hexEncode(byte b,
boolean lowercase) |
static void |
hexEncode(char[] charArray,
int i,
byte b) |
static int |
putInt(int val,
byte[] bytes,
int offset)
Puts a int number to byte array
|
static void |
tailCopy(byte[] src,
byte[] dest) |
static void |
tailCopy(byte[] src,
int destLen) |
static void |
tailCopy(byte[] src,
int srcFrom,
int srcLen,
byte[] dest,
int destFrom,
int destLen)
copy src to dest
从尾部开始拷贝src到dest:
若src数据不足则在dest前面补0
若src数据有多则舍去src前面的数据
|
static void |
tailCopy(byte[] src,
int srcFrom,
int srcLen,
byte[] dest,
int destFrom,
int destLen,
byte heading)
copy src to dest
从尾部开始拷贝src到dest:
若src数据不足则在dest前面补heading
若src数据有多则舍去src前面的数据
|
static BigDecimal |
toBigDecimal(byte[] bytes)
Converts a byte array to a BigDecimal
|
static BigDecimal |
toBigDecimal(byte[] bytes,
int offset,
int length)
Converts a byte array to a BigDecimal value
|
static BigInteger |
toBigInteger(byte[] bytes)
Converts byte array to positive BigInteger
|
static String |
toBinary(byte... array)
convert the byte array to binary string
byte:
-1: 11111111
0: 00000000
127: 01111111
-128: 10000000
|
static byte[] |
toBytes(BigDecimal val)
Convert a BigDecimal value to a byte array
|
static byte[] |
toBytes(char value) |
static byte[] |
toBytes(char[] chars)
Converts char array to byte array
|
static byte[] |
toBytes(char[] chars,
Charset charset)
Converts char array to byte array
|
static byte[] |
toBytes(double value) |
static byte[] |
toBytes(float value) |
static byte[] |
toBytes(int value) |
static byte[] |
toBytes(long value)
convert long value to byte array
|
static byte[] |
toBytes(short value) |
static byte[] |
toBytes(String value)
Converts String to byte array
|
static byte[] |
toBytes(String value,
Charset charset)
Converts string to byte array
|
static char |
toChar(byte[] bytes) |
static char |
toChar(byte[] bytes,
int fromIdx) |
static char[] |
toCharArray(byte[] bytes)
Converts byte array to char array
|
static char[] |
toCharArray(byte[] bytes,
Charset charset)
Converts byte array to char array
|
static double |
toDouble(byte[] bytes) |
static double |
toDouble(byte[] bytes,
int fromIdx) |
static float |
toFloat(byte[] bytes) |
static float |
toFloat(byte[] bytes,
int fromIdx) |
static String |
toHex(long value)
Long value to hex string
|
static String |
toHex(long value,
boolean lowercase)
Long value to hex string
|
static int |
toInt(byte[] bytes) |
static int |
toInt(byte[] bytes,
int fromIdx) |
static long |
toLong(byte[] bytes)
convert byte array to long number
|
static long |
toLong(byte[] bytes,
int fromIdx)
convert byte array to long number
|
static short |
toShort(byte[] bytes) |
static short |
toShort(byte[] bytes,
int fromIdx) |
static String |
toString(byte[] bytes)
Converts byte array to String
|
static String |
toString(byte[] bytes,
Charset charset)
Converts byte array to String
|
public static String hexDump(byte[] data, int chunk, int block)
HexDump.dump(byte[], long, java.io.OutputStream, int),
CharacterEncoder.encode(byte[], java.io.OutputStream);data - 字节数组chunk - 每行块数block - 每块大小public static String hexDump(byte[] data)
public static String toBinary(byte... array)
array - public static void hexEncode(char[] charArray,
int i,
byte b)
public static String hexEncode(byte b, boolean lowercase)
public static String hexEncode(byte[] bytes)
public static String hexEncode(byte[] bytes, boolean lowercase)
bytes - lowercase - public static byte[] hexDecode(String hex)
hex - public static String toString(byte[] bytes)
bytes - the byte arraypublic static String toString(byte[] bytes, Charset charset)
bytes - the byte arraycharset - the Charsetpublic static byte[] toBytes(String value)
value - the string valuepublic static byte[] toBytes(String value, Charset charset)
value - the string valuecharset - the charsetpublic static char[] toCharArray(byte[] bytes)
bytes - the byte arraypublic static char[] toCharArray(byte[] bytes,
Charset charset)
bytes - the byte arraycharset - the charsetpublic static byte[] toBytes(char[] chars)
chars - the char arraypublic static byte[] toBytes(char[] chars,
Charset charset)
chars - the char arraycharset - the charsetpublic static byte[] toBytes(short value)
public static short toShort(byte[] bytes)
public static short toShort(byte[] bytes,
int fromIdx)
public static byte[] toBytes(char value)
public static char toChar(byte[] bytes)
public static char toChar(byte[] bytes,
int fromIdx)
public static byte[] toBytes(int value)
public static int toInt(byte[] bytes)
public static int toInt(byte[] bytes,
int fromIdx)
public static byte[] toBytes(long value)
value - the long numberpublic static long toLong(byte[] bytes,
int fromIdx)
bytes - the byte arrayfromIdx - the byte array offsetpublic static long toLong(byte[] bytes)
bytes - the byte arraypublic static String toHex(long value)
value - the long valuepublic static String toHex(long value, boolean lowercase)
value - the long valuelowercase - true if lowercase hex string, else uppercasepublic static byte[] toBytes(float value)
public static float toFloat(byte[] bytes)
public static float toFloat(byte[] bytes,
int fromIdx)
public static byte[] toBytes(double value)
public static double toDouble(byte[] bytes)
public static double toDouble(byte[] bytes,
int fromIdx)
public static byte[] toBytes(BigDecimal val)
val - public static int putInt(int val,
byte[] bytes,
int offset)
val - the int valuebytes - the byte arrayoffset - the byte array start offsetpublic static BigDecimal toBigDecimal(byte[] bytes)
bytes - public static BigDecimal toBigDecimal(byte[] bytes, int offset, int length)
bytes - offset - length - public static BigInteger toBigInteger(byte[] bytes)
bytes - the byte arraypublic static byte[] concat(byte[] first,
byte[]... rest)
first - first byte array of argsrest - others byte arraypublic static void tailCopy(byte[] src,
int destLen)
public static void tailCopy(byte[] src,
byte[] dest)
public static void tailCopy(byte[] src,
int srcFrom,
int srcLen,
byte[] dest,
int destFrom,
int destLen)
src - srcFrom - srcLen - dest - destFrom - destLen - public static void tailCopy(byte[] src,
int srcFrom,
int srcLen,
byte[] dest,
int destFrom,
int destLen,
byte heading)
src - srcFrom - srcLen - dest - destFrom - destLen - heading - public static void headCopy(byte[] src,
byte[] dest)
src - dest - public static void headCopy(byte[] src,
int srcFrom,
int srcLen,
byte[] dest,
int destFrom,
int destLen,
byte tailing)
public static long crc32(byte[] bytes)
Copyright © 2023. All rights reserved.