Here you can find the source of toHexString(byte[] b, int off, int len)
public static String toHexString(byte[] b, int off, int len)
//package com.java2s; /*/*ww w .j ava2s .c o m*/ * @(#)ArrayUtil.java * * Copyright (c) 2003-2010 Werner Randelshofer * Hausmatt 10, Immensee, CH-6405, Switzerland * All rights reserved. * * The copyright of this software is owned by Werner Randelshofer. * You may not use, copy or modify this software, except in * accordance with the license agreement you entered into with * Werner Randelshofer. For details see accompanying license terms. */ public class Main { private final static char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String toHexString(byte[] b, int off, int len) { StringBuffer buf = new StringBuffer(); int end = off + len; for (; off < end; off++) { buf.append(hexChars[(b[off] & 0xf0) >>> 4]); buf.append(hexChars[b[off] & 0x0f]); } return buf.toString(); } public static String toHexString(byte[] b) { return toHexString(b, 0, b.length); } }