Java Utililty Methods Hex Convert To

List of utility methods to do Hex Convert To

Description

The list of methods to do Hex Convert To are organized into topic(s).

Method

StringconvertHextoASCII(String text)
convert Hexto ASCII
String convertedString = text;
String replacement;
int decimal;
int iStart;
while (convertedString.contains("&#x")) {
    iStart = convertedString.indexOf("&#x");
    replacement = convertedString.substring(iStart + 3, iStart + 5);
    decimal = Integer.parseInt(replacement, 16);
...
charconvertHexToChar(String hex)
Wandle 4-stellige Hexadezimalkodierung in Unicode-Zeichen um (z.B.
return (char) convertHexToInt(hex);
floatconvertHexToFloat(long hexValue)
Converts a hex value given by a long to a float value.
return Float.intBitsToFloat((int) hexValue);
byte[]fromHex(byte[] hex)
Converts the given hex array to a byte array
byte[] bytes = new byte[hex.length / 2];
for (int i = 0; i < bytes.length; i++) {
    int v = i * 2;
    int b = Character.digit(hex[v], 16) << 4;
    b = b | Character.digit(hex[v + 1], 16);
    bytes[i] = (byte) (b & 0xFF);
return bytes;
...
intfromHex(char c)
from Hex
if (c >= '0' && c <= '9') {
    return c - '0';
if (c >= 'A' && c <= 'F') {
    return c - 'A' + 10;
if (c >= 'a' && c <= 'f') {
    return c - 'a' + 10;
...
intfromHex(char c)
Translates a hex char into an int.
if (c >= '0' && c <= '9')
    return c - '0';
if (c >= 'A' && c <= 'F')
    return c - 'a' + 10;
if (c >= 'a' && c <= 'f')
    return c - 'a' + 10;
throw new IllegalArgumentException("bad hex char " + c);
bytefromHex(char hi, char lo)
from Hex
int hiValue = HEX_DIGITS.indexOf(((hi >= 'A') && (hi <= 'F')) ? ('a' + (hi - 'A')) : hi);
int loValue = HEX_DIGITS.indexOf(((lo >= 'A') && (lo <= 'F')) ? ('a' + (lo - 'A')) : lo);
if ((hiValue < 0) || (loValue < 0)) {
    throw new NumberFormatException(
            "fromHex(" + new String(new char[] { hi, lo }) + ") non-HEX characters");
return (byte) ((hiValue << 4) + loValue);
byte[]fromHex(CharSequence cs)
Converts a character sequence of hexadecimal characters to byte array.
if (cs.length() % 2 != 0) {
    throw new IllegalArgumentException("Odd length: " + cs.length());
byte[] r = new byte[cs.length() / 2];
for (int i = 0; i < r.length; i++) {
    r[i] = (byte) ((fromHex(cs.charAt(i * 2)) << 4) | fromHex(cs.charAt(i * 2 + 1)));
return r;
...
intfromHex(final CharSequence s)
from Hex
return fromHex(s, 0, length(s));
byte[]fromHex(final String hex)
Convert a string of hex to bytes.
char[] ch = hex.toCharArray();
if (ch.length % 2 != 0) {
    throw new UnsupportedOperationException("The hex string must contain an even number of digits");
byte[] b = new byte[ch.length / 2];
char ch0, ch1;
try {
    for (int i = 0; i < ch.length; i += 2) {
...