Here you can find the source of fromBase16(String data)
public static byte[] fromBase16(String data)
//package com.java2s; /* Copyright (C) 2009 Mobile Sorcery AB //from w ww . ja v a2 s .com This program is free software; you can redistribute it and/or modify it under the terms of the Eclipse Public License v1.0. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Eclipse Public License v1.0 for more details. You should have received a copy of the Eclipse Public License v1.0 along with this program. It is also available at http://www.eclipse.org/legal/epl-v10.html */ public class Main { public static byte[] fromBase16(String data) { boolean extraByte = data.length() % 2 == 1; byte[] result = new byte[data.length() / 2 + (extraByte ? 1 : 0)]; for (int i = 0; i < result.length; i++) { int value = Integer.parseInt(data.substring(2 * i, Math.min(2 * i + 2, data.length())), 16); result[i] = (byte) (value & 0xff); } return result; } }