Java tutorial
//package com.java2s; //License from project: LGPL public class Main { private static final int STR_ADDRESS_LENGTH = 17; private static final int ADDRESS_LENGTH = 6; public static byte[] addressToBytes(String address) { if (address == null || address.length() != STR_ADDRESS_LENGTH) { return null; } byte[] result = new byte[ADDRESS_LENGTH]; for (int i = 0; i < ADDRESS_LENGTH; ++i) { result[i] = Byte.valueOf(address.substring(3 * i, 3 * i + 2), 16); } return result; } }