Here you can find the source of toByteByHex(String address)
public static byte[] toByteByHex(String address)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] toByteByHex(String address) { if (address == null) { throw new IllegalArgumentException("address is invalid"); }//from w w w . j a v a 2 s . co m int len = address.length(); if (len < 8) { throw new IllegalArgumentException("address is invalid"); } byte[] buf; if (len >= 12) { buf = new byte[6]; } else { buf = new byte[4]; } int pos = 0; if (len >= 12) { buf[pos++] = (byte) Integer.parseInt(address.substring(10, 12), 16); buf[pos++] = (byte) Integer.parseInt(address.substring(8, 10), 16); } buf[pos++] = (byte) Integer.parseInt(address.substring(0, 2), 16); buf[pos++] = (byte) Integer.parseInt(address.substring(2, 4), 16); buf[pos++] = (byte) Integer.parseInt(address.substring(4, 6), 16); buf[pos++] = (byte) Integer.parseInt(address.substring(6, 8), 16); return buf; } }