Here you can find the source of toHex(final char[] dest, int destPos, final byte[] src, final int srcStart, final int srcLength)
public static final int toHex(final char[] dest, int destPos, final byte[] src, final int srcStart, final int srcLength)
//package com.java2s; //License from project: Apache License public class Main { /**/* ww w. j a v a2s .co m*/ * All possible chars for representing a number as a String */ final static char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; public static final int toHex(final char[] dest, int destPos, final byte[] src, final int srcStart, final int srcLength) { for (int i = 0; i < srcLength; i++) { int u = src[i] & 255; dest[destPos + 1] = digits[u & 0x0F]; u >>>= 4; dest[destPos] = digits[u & 0x0F]; destPos += 2; } return srcLength << 1; } }