Here you can find the source of toHex(byte[] text)
Parameter | Description |
---|---|
text | The array to convert |
public static String toHex(byte[] text)
//package com.java2s; public class Main { /**/*from w ww. j a v a2 s . c om*/ * The array used for conversion to hexadecimal */ public final static char[] HEX_ARRAY = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /** * Utility method which converts a byte[] to a hexadecimal string of characters, in lower case * * @param text The array to convert * @return A string representation */ public static String toHex(byte[] text) { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < text.length; i++) { buffer.append(HEX_ARRAY[0x0f & (text[i] >> 4)]); buffer.append(HEX_ARRAY[0x0f & text[i]]); } return buffer.toString(); } }