Java tutorial
//package com.java2s; public class Main { public static byte[] setDevid(String devid) { String str = "0123456789ABCDEF"; char[] hexs = devid.toCharArray(); byte[] bytes = new byte[devid.length() / 2]; int n; for (int i = 0; i < bytes.length; i++) { n = str.indexOf(hexs[2 * i]) * 16; n += str.indexOf(hexs[2 * i + 1]); bytes[i] = (byte) (n & 0xff); } return bytes; } }