Here you can find the source of toHexString(byte[] data, int start, int len)
public static String toHexString(byte[] data, int start, int len)
//package com.java2s; /******************************************************************************* * * Copyright (c) 2004-2011 Oracle Corporation. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: //from w w w . ja v a 2 s . c om * * Kohsuke Kawaguchi, Winston Prakash * * *******************************************************************************/ public class Main { public static String toHexString(byte[] data, int start, int len) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < len; i++) { int b = data[start + i] & 0xFF; if (b < 16) { buf.append('0'); } buf.append(Integer.toHexString(b)); } return buf.toString(); } public static String toHexString(byte[] bytes) { return toHexString(bytes, 0, bytes.length); } }