Here you can find the source of toHexString(byte[] byteArray)
public static String toHexString(byte[] byteArray)
//package com.java2s; /*//w w w . j ava 2s .c o m Copyright (C) 2013 Tobias B odify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. jsync 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 GNU General Public License for more details. You should have received a copy of the GNU General Public License along with jsync. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static String toHexString(byte[] byteArray) { final StringBuilder ret = new StringBuilder(); for (final byte b : byteArray) { ret.append(toHexString(b)); } return ret.toString(); } private static String toHexString(byte b) { return Character.toString(toHexChar((b & 0xFF) >> 4)) + Character.toString(toHexChar(b & 0x0F)); } private static char toHexChar(int nibble) { if (nibble < 10) { return (char) ('0' + nibble); } else { return (char) ('A' + nibble - 10); } } }