Here you can find the source of toByteArray(String hex)
Parameter | Description |
---|---|
hexStr | a parameter |
public static byte[] toByteArray(String hex)
//package com.java2s; //License from project: Open Source License public class Main { /***/*from w ww. j a v a2 s . c o m*/ * Convert hex string to byte array * @param hexStr * @return */ public static byte[] toByteArray(String hex) { byte[] byteArray = new byte[hex.length() / 2]; for (int i = 0; i < byteArray.length; i++) { byteArray[i] = (byte) Integer.parseInt(hex.substring((i * 2), ((i * 2) + 2)), 16); } return byteArray; } }