16進数表記文字列(00 ~ FF)*をbyte配列に変換
/** * 16進数表記文字列(00 ~ FF)*をbyte配列に変換する * * @param hexStr * 16進数表記文字列(00 ~ FF) * @return byte配列 */ public static byte[] hexStringToBytes(String hexStr) { if (hexStr.length() % 2 != 0) { throw new IllegalArgumentException(); } int bytesLength = hexStr.length() / 2; byte[] result = new byte[bytesLength]; for (int i = 0; i < bytesLength; i++) { result[i] = (byte) Integer.parseInt(hexStr.substring(2 * i, 2 * (i + 1)), 16); } return result; }