Here you can find the source of hexStringToByteArray(String s)
static public byte[] hexStringToByteArray(String s)
//package com.java2s; /**//from w w w. j a v a 2 s . com * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by * the Eclipse Foundation * * or (per the licensee's choosing) * * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ public class Main { static public byte[] hexStringToByteArray(String s) { int len = s.length(); byte[] ba = new byte[len / 2]; for (int i = 0; i < ba.length; i++) { int j = i * 2; int t = Integer.parseInt(s.substring(j, j + 2), 16); byte b = (byte) (t & 0xFF); ba[i] = b; } return ba; } }