Android String to Hex Byte Array Convert hexStr2Bytes(String src)

Here you can find the source of hexStr2Bytes(String src)

Description

hex Str Bytes

Declaration

public static byte[] hexStr2Bytes(String src) 

Method Source Code

//package com.java2s;

public class Main {

    public static byte[] hexStr2Bytes(String src) {
        int m = 0, n = 0;
        int l = src.length() / 2;
        byte[] ret = new byte[l];
        for (int i = 0; i < l; i++) {
            m = i * 2 + 1;/*w w w .j  a  v a2 s .c om*/
            n = m + 1;
            ret[i] = Byte.decode("0x" + src.substring(i * 2, m)
                    + src.substring(m, n));
        }
        return ret;
    }
}

Related

  1. stringToHexByte(String str)
  2. hexStringToBytes(String hexString)
  3. hexStringToBytes(String hex)
  4. getBytes(String hexString)
  5. hexStringToBytes(String hexString)
  6. stringToHex(String ids)