Here you can find the source of bytesToHexAppend(byte[] bs, int off, int length, StringBuffer sb)
public static final void bytesToHexAppend(byte[] bs, int off, int length, StringBuffer sb)
//package com.java2s; //License from project: Apache License public class Main { public static final void bytesToHexAppend(byte[] bs, int off, int length, StringBuffer sb) { sb.ensureCapacity(sb.length() + length * 2); for (int i = off; i < (off + length) && i < bs.length; i++) { sb.append(Character.forDigit((bs[i] >>> 4) & 0xf, 16)); sb.append(Character.forDigit(bs[i] & 0xf, 16)); }/* w w w . j av a 2 s . c om*/ } }