* The hexadecimal representation to decode
* @return The decoded byte array
* @see Integer#parseInt(java.lang.String, int)
+ * @throw NumberFormatException if the given string is not the hexadecimal
+ * representation of a byte array
*/
public static byte[] toByte(String hexString) {
if ((hexString.length() & 0x01) == 0x01) {
/* odd length, this is not correct. */
- throw new IllegalArgumentException("hex string must have even length.");
+ throw new NumberFormatException("hex string must have even length.");
}
byte[] dataBytes = new byte[hexString.length() / 2];
for (int stringIndex = 0; stringIndex < hexString.length(); stringIndex += 2) {