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

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

Description

hex Str Byte Arr

Declaration

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

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] hexStr2ByteArr(String paramString)
            throws Exception {
        byte[] arrayOfByte1 = paramString.getBytes();
        int i = arrayOfByte1.length;
        byte[] arrayOfByte2 = new byte[i / 2];
        for (int j = 0; j < i; j += 2) {
            String str = new String(arrayOfByte1, j, 2);
            arrayOfByte2[(j / 2)] = (byte) Integer.parseInt(str, 16);
        }/*from   www . java  2  s.  co  m*/
        return arrayOfByte2;
    }
}

Related

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