Android Hex String to Byte Array Convert hexStr2ByteArr(String str)

Here you can find the source of hexStr2ByteArr(String str)

Description

hex Str Byte Arr

Declaration

public static byte[] hexStr2ByteArr(String str) throws Exception 

Method Source Code

//package com.java2s;

public class Main {

    public static byte[] hexStr2ByteArr(String str) throws Exception {
        byte[] arrB = str.getBytes();
        int iLen = arrB.length;

        byte[] arrOut = new byte[iLen / 2];
        for (int i = 0; i < iLen; i = i + 2) {
            String strTmp = new String(arrB, i, 2);
            arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
        }/*from   w w w.  ja v  a 2s  . co m*/
        return arrOut;
    }
}

Related

  1. hexToByte(char char1, char char2)
  2. hexStringToByteArray(String s)
  3. hexStringToBytes(String s)
  4. hex2bytes(String hex)
  5. hexStr2ByteArr(String paramString)
  6. hexStr2Bytes(String src)
  7. hexStr2Str(String hexStr)
  8. toByte(String hexString)
  9. toBytesFromHexString(String digits)