Here you can find the source of bytesToHex(StringBuffer buff, byte[] src, int start, int end)
private static void bytesToHex(StringBuffer buff, byte[] src, int start, int end)
//package com.java2s; /******************************************************************************* * I N T E L C O R P O R A T I O N * /*from w w w .ja v a 2 s . co m*/ * Functional Group: Fabric Viewer Application * * File Name: StringUtils.java * * Archive Source: $Source$ * * Archive Log: $Log$ * Archive Log: Revision 1.8 2015/08/17 18:48:51 jijunwan * Archive Log: PR 129983 - Need to change file header's copyright text to BSD license txt * Archive Log: - change backend files' headers * Archive Log: * Archive Log: Revision 1.7 2015/06/10 19:36:43 jijunwan * Archive Log: PR 129153 - Some old files have no proper file header. They cannot record change logs. * Archive Log: - wrote a tool to check and insert file header * Archive Log: - applied on backend files * Archive Log: * * Overview: * * @author: jijunwan * ******************************************************************************/ public class Main { private static void bytesToHex(StringBuffer buff, byte[] src, int start, int end) { String groupSeparator = ""; for (int i = start; i < end; i = i + 2) { buff.append(groupSeparator); int group = ((src[i] << 8) & 0xff00) | ((src[i + 1]) & 0xff); buff.append(Integer.toHexString(group)); groupSeparator = ":"; } } }