Here you can find the source of printBytesToString(byte[] bytes, String structName)
public static void printBytesToString(byte[] bytes, String structName)
//package com.java2s; //License from project: Apache License public class Main { public static void printBytesToString(byte[] bytes, String structName) { System.out.println("*************" + structName + "**************"); StringBuilder stringBuilder = new StringBuilder(); for (Byte byteStr : bytes) { String hexByteStr = Integer.toHexString(byteStr.intValue()); if (hexByteStr.length() < 2) { stringBuilder.append("0"); }// ww w .j a va 2 s. c o m if (hexByteStr.length() > 2) { hexByteStr = hexByteStr.substring(hexByteStr.length() - 2, hexByteStr.length()); } stringBuilder.append(hexByteStr); stringBuilder.append(" "); } System.out.println(stringBuilder.toString()); System.out.println("************************************"); } }