Here you can find the source of bytesToString(byte[] bytes)
public static String bytesToString(byte[] bytes)
//package com.java2s; public class Main { public static String bytesToString(byte[] bytes) { StringBuffer sBuffer = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { sBuffer.append(byteToString(bytes[i])); if (i != bytes.length - 1) sBuffer.append("-"); }/*from w w w. j ava 2 s . com*/ return sBuffer.toString(); } public static String byteToString(byte b) { String result = String.valueOf(Integer.toHexString(b & 0xFF)); if (result.length() == 1) result = "0" + result; return result.toUpperCase(); } }