public final class Hex
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
bytesToASCIIString(byte[] data) |
static java.lang.String |
bytesToHexString(byte[] text)
Converts a byte array to capitalized hexadecimal text.
|
static java.lang.String |
bytesToHexString(byte[] text,
int numRow) |
static java.lang.String |
bytesToHexString(byte[] text,
int offset,
int length) |
static java.lang.String |
bytesToHexString(byte[] text,
int offset,
int length,
int numRow)
Converts part of a byte array to capitalized hexadecimal text.
|
static java.lang.String |
bytesToPrettyString(byte[] data)
Gets a human readable hexadecimal representation of
data
with spaces. |
static java.lang.String |
bytesToPrettyString(byte[] data,
int columns,
boolean useIndex,
int indexPadWidth,
java.lang.String altIndex,
boolean useASCII)
Gets a human readable hexadecimal representation of
data
with spaces and newlines in columns columns. |
static java.lang.String |
bytesToSpacedHexString(byte[] data)
Hexadecimal representation of
data with spaces between
individual bytes. |
static java.lang.String |
byteToHexString(byte b)
Converts the byte
b to capitalized hexadecimal text. |
static byte |
hexStringToByte(java.lang.String text)
Converts the hexadecimal string in
text to a byte. |
static byte[] |
hexStringToBytes(java.lang.String text)
Converts the hexadecimal string in
text to
a byte array. |
static int |
hexStringToInt(java.lang.String text)
Converts the hexadecimal string in
text to
an integer. |
static short |
hexStringToShort(java.lang.String text)
Converts the hexadecimal string in
text to a short. |
static java.lang.String |
intToHexString(int n)
Converts the integer
n to capitalized hexadecimal text. |
static java.lang.String |
shortToHexString(short s)
Converts the short
s to capitalized hexadecimal text. |
static byte[][] |
split(byte[] src,
int width)
Splits the byte array
src into a number of byte arrays of
length width. |
static java.lang.String |
toHexString(byte[] text)
Converts a byte array to capitalized hexadecimal text.
|
static java.lang.String |
toHexString(byte[] text,
int numRow) |
public static java.lang.String byteToHexString(byte b)
b to capitalized hexadecimal text.
The result will have length 2 and only contain the characters '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.b - the byte to convert.b.public static java.lang.String shortToHexString(short s)
s to capitalized hexadecimal text.
The result will have length 4 and only contain the characters '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.s - the short to convert.s.public static java.lang.String intToHexString(int n)
n to capitalized hexadecimal text.
The result will have length 8 and only contain the characters '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.n - the integer to convert.n.public static java.lang.String bytesToHexString(byte[] text)
text and will only contain the characters '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.text - The byte array to convert.text.public static java.lang.String bytesToHexString(byte[] text,
int numRow)
public static java.lang.String toHexString(byte[] text)
text and will only contain the characters '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.text - The byte array to convert.text.public static java.lang.String toHexString(byte[] text,
int numRow)
public static java.lang.String bytesToHexString(byte[] text,
int offset,
int length,
int numRow)
offset until (excluding)
index offset + length.
The length of the resulting string will be twice the length
text and will only contain the characters '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'.text - the byte array to convert.offset - where to start.length - how many bytes to convert.numRow - number of bytes to be put one in one row of outputtext.public static java.lang.String bytesToHexString(byte[] text,
int offset,
int length)
public static byte hexStringToByte(java.lang.String text)
throws java.lang.NumberFormatException
text to a byte.text - the string to converttext.java.lang.NumberFormatException - if text does not contain
a valid hexadecimal byte representation.public static short hexStringToShort(java.lang.String text)
throws java.lang.NumberFormatException
text to a short.text - the string to converttext.java.lang.NumberFormatException - if text does not contain
a valid hexadecimal short representation.public static int hexStringToInt(java.lang.String text)
throws java.lang.NumberFormatException
text to
an integer.text - the string to converttext.java.lang.NumberFormatException - if text does not contain
a valid hexadecimal integer representation.public static byte[] hexStringToBytes(java.lang.String text)
throws java.lang.NumberFormatException
text to
a byte array. If text has an odd number of
characters, a 0 is inserted at the beginning.text - the string to convert.text.java.lang.NumberFormatException - if text does not contain
a valid hexadecimal string.public static java.lang.String bytesToSpacedHexString(byte[] data)
data with spaces between
individual bytes.data - the byte array to print.data.public static java.lang.String bytesToASCIIString(byte[] data)
public static byte[][] split(byte[] src,
int width)
src into a number of byte arrays of
length width. (Plus one of length less than width if
width does not divide the length of src.)src - the byte array to split.width - a positive number.public static java.lang.String bytesToPrettyString(byte[] data)
data
with spaces.
Includes and index and ASCII representation.data - the byte array to print.data.public static java.lang.String bytesToPrettyString(byte[] data,
int columns,
boolean useIndex,
int indexPadWidth,
java.lang.String altIndex,
boolean useASCII)
data
with spaces and newlines in columns columns.
Will print an index before each line if useIndex is
true.
Will print an ASCII representation after each line if
useASCII is true.data - the byte array to print.columns - the number of bytes per line.useIndex - a boolean indicating whether each line should be started
with an index.indexPadWidth - the padding width for index.altIndex - string to prefix if no index is used.useASCII - a boolean indicating whether each line should be ended
with an ASCII representation of the bytes in that line.data.Copyright © 2023. All rights reserved.