Here you can find the source of toHexString(byte[] bytes)
private static String toHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] HEX_DIGITS = "0123456789abcdef".toCharArray(); private static String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(bytes.length * 3); for (int b : bytes) { b &= 0xff;/*from w ww. j a v a 2s. c o m*/ sb.append(HEX_DIGITS[b >> 4]); sb.append(HEX_DIGITS[b & 15]); sb.append(' '); } return sb.toString(); } }