public class HexUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
EMPTY_STRING |
static String |
NEWLINE |
| 构造器和说明 |
|---|
HexUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static char |
byteToChar(byte chr)
返回ASCII字符
|
static String |
byteToHexString(int value) |
static String |
byteToHexStringPadded(int value) |
static short |
getUnsignedByte(int value)
获取无符号byte值
|
static String |
hexDump(byte[] array) |
static String |
hexDump(byte[] array,
int offset,
int length)
格式化为16进制字符串
|
static boolean |
isOutOfBounds(int index,
int length,
int capacity) |
static void |
main(String[] args) |
static String |
prettyHexDump(byte[] buffer) |
static String |
prettyHexDump(byte[] buffer,
int offset,
int length)
格式化为如下样式
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 4d 49 47 66 4d 41 30 47 43 53 71 47 53 49 62 33 |MIGfMA0GCSqGSIb3|
|00000010| 44 51 45 42 41 51 55 41 41 34 47 4e 41 44 43 42 |DQEBAQUAA4GNADCB|
|00000020| 69 51 4b 42 67 51 43 39 32 55 54 4f 61 51 48 55 |iQKBgQC92UTOaQHU|
|00000030| 6d 4c 4f 2f 31 2b 73 43 6b 70 66 76 52 47 68 6d |mLO/1+sCkpfvRGhm|
|00000040| 71 38 70 30 66 33 5a 79 42 71 6b 41 72 69 4d 6b |q8p0f3ZyBqkAriMk|
|000000d0| 31 51 49 44 41 51 41 42 |1QIDAQAB |
+--------+-------------------------------------------------+----------------+
|
static String |
SimplePrettyHexDump(byte[] bytes) |
static String |
SimplePrettyHexDump(byte[] bytes,
int offset,
int length)
将字节转换成十六进制字符串
|
public static final String NEWLINE
public static short getUnsignedByte(int value)
value - public static String byteToHexString(int value)
public static String byteToHexStringPadded(int value)
public static final char byteToChar(byte chr)
chr - public static String hexDump(byte[] array)
public static String hexDump(byte[] array, int offset, int length)
array - offset - length - public static String prettyHexDump(byte[] buffer)
public static String prettyHexDump(byte[] buffer, int offset, int length)
格式化为如下样式
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 4d 49 47 66 4d 41 30 47 43 53 71 47 53 49 62 33 |MIGfMA0GCSqGSIb3|
|00000010| 44 51 45 42 41 51 55 41 41 34 47 4e 41 44 43 42 |DQEBAQUAA4GNADCB|
|00000020| 69 51 4b 42 67 51 43 39 32 55 54 4f 61 51 48 55 |iQKBgQC92UTOaQHU|
|00000030| 6d 4c 4f 2f 31 2b 73 43 6b 70 66 76 52 47 68 6d |mLO/1+sCkpfvRGhm|
|00000040| 71 38 70 30 66 33 5a 79 42 71 6b 41 72 69 4d 6b |q8p0f3ZyBqkAriMk|
|000000d0| 31 51 49 44 41 51 41 42 |1QIDAQAB |
+--------+-------------------------------------------------+----------------+
buffer - offset - length - public static boolean isOutOfBounds(int index,
int length,
int capacity)
public static String SimplePrettyHexDump(byte[] bytes)
public static String SimplePrettyHexDump(byte[] bytes, int offset, int length)
bytes - 数据offset - 起始位置length - 从起始位置开始的长度public static void main(String[] args)
Copyright © 2020. All rights reserved.