Here you can find the source of encodeHex(byte[] data)
private static String encodeHex(byte[] data)
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import java.util.Formatter; public class Main { private static String encodeHex(byte[] data) { StringBuilder sb = new StringBuilder(data.length * 2); Formatter formatter = new Formatter(sb); for (byte b : data) { formatter.format("%02x", b); }/*from w ww. java 2 s .c om*/ return sb.toString(); } }