Here you can find the source of hexStr2Bytes(String src)
public static byte[] hexStr2Bytes(String src)
//package com.java2s; public class Main { public static byte[] hexStr2Bytes(String src) { int m = 0, n = 0; int l = src.length() / 2; System.out.println(l);/*from w ww.java2 s .c o m*/ byte[] ret = new byte[l]; for (int i = 0; i < l; i++) { m = i * 2 + 1; n = m + 1; ret[i] = uniteBytes(src.substring(i * 2, m), src.substring(m, n)); } return ret; } private static byte uniteBytes(String src0, String src1) { byte b0 = Byte.decode("0x" + src0).byteValue(); b0 = (byte) (b0 << 4); byte b1 = Byte.decode("0x" + src1).byteValue(); byte ret = (byte) (b0 | b1); return ret; } }