[New] Added StringHelper.fromHexStringByte()

This commit is contained in:
Robert von Burg 2017-09-06 14:29:23 +02:00
parent eaec58a223
commit 96108a4c4e
1 changed files with 7 additions and 0 deletions

View File

@ -143,6 +143,13 @@ public class StringHelper {
}
}
public static byte fromHexStringByte(String encoded) {
if (encoded.length() != 2)
throw new IllegalArgumentException("Input string must be exactly two characters long."); //$NON-NLS-1$
byte result = (byte) Integer.parseInt(encoded, 16);
return result;
}
/**
* Returns a byte array of a given string by converting each character of the string to a number base 16
*