Here you can find the source of toHexByte(String str, int offset, int length)
public static byte[] toHexByte(String str, int offset, int length)
//package com.java2s; public class Main { public static byte[] toHexByte(String str, int offset, int length) { byte[] data = new byte[(length - offset) * 2]; int end = offset + length; int high_nibble; int low_nibble; for (int i = offset; i < end; i++) { char ch = str.charAt(i); high_nibble = (ch & 0xF0) >>> 4; low_nibble = ch & 0x0F;/*ww w . ja v a2 s. co m*/ data[i] = (byte) high_nibble; data[i + 1] = (byte) low_nibble; } return data; } }