Here you can find the source of dump(byte[] bytes)
public static StringBuilder dump(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w .j a v a 2 s.co m*/ * dump byte [] as StringBuilder "0x00, ..., 0xFF" */ public static StringBuilder dump(byte[] bytes) { if (bytes == null) throw new IllegalArgumentException("null bytes"); return dump(bytes, 0, bytes.length); } public static StringBuilder dump(byte[] bytes, int offset, int length) { if (bytes == null) throw new IllegalArgumentException("null bytes"); StringBuilder sbuf = new StringBuilder(); int i, cnt = offset + length; for (i = offset; i < cnt; i++) { if (i > offset) sbuf.append(", "); sbuf.append("(byte)0x" + Integer.toHexString(((int) bytes[i]) & 0xFF).toUpperCase()); } return sbuf; } }