Here you can find the source of toBase16(byte[] data)
public static String toBase16(byte[] data)
//package com.java2s; /* Copyright (C) 2009 Mobile Sorcery AB //from w w w.j a v a2 s .c o m 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 final char[] BASE16_CHARS = "0123456789ABCDEF".toCharArray(); public static String toBase16(byte[] data) { return toBase16(data, 0, data.length); } public static String toBase16(byte[] data, int offset, int length) { char[] result = new char[length * 2]; for (int i = 0; i < length; i++) { result[2 * i] = BASE16_CHARS[(data[offset + i] >> 4) & 0xf]; result[2 * i + 1] = BASE16_CHARS[data[offset + i] & 0xf]; } return new String(result); } }