Here you can find the source of toHexString(byte bytes[])
public static String toHexString(byte bytes[])
//package com.java2s; //License from project: Open Source License public class Main { public static String toHexString(byte bytes[]) { return toHexString(bytes, 0, bytes.length); }/*w w w . j a va 2 s . c o m*/ public static String toHexString(byte bytes[], int start, int len) { if (len == 0) return "[]"; StringBuffer sb = new StringBuffer(); sb.append('['); sb.append(Integer.toHexString(bytes[start] & 0xff)); for (int i = 1; i < len; i++) sb.append(',').append(Integer.toHexString(bytes[start + i] & 0xFF)); sb.append("]"); return sb.toString(); } public static String toString(byte bytes[]) { return toString(bytes, 0, bytes.length); } public static String toString(byte bytes[], int start, int len) { if (len == 0) return "[]"; StringBuffer sb = new StringBuffer(); sb.append('['); sb.append(Integer.toString(bytes[start] & 0xff)); for (int i = 1; i < len; i++) sb.append(',').append(Integer.toString(bytes[start + i] & 0xFF)); sb.append("]"); return sb.toString(); } }