public static byte[] hexStringToByteArray(String hexString) {
        int length = hexString.length();
        byte[] buffer = new byte[(length + 1) / 3];

        for (int i = 0; i < length; i += 3) {
            buffer[i / 3] = (byte) ((toByte(hexString.charAt(i)) << 4) | toByte(hexString.charAt(i + 1)));
        }

        return buffer;
    }
accepts any separator, e.g. space or newline
usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/util/HexDump.java