Java tutorial
//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); } return sb.toString(); } }