Here you can find the source of toHexadecimal(final byte[] array)
Parameter | Description |
---|---|
array | Array to convert |
public static String toHexadecimal(final byte[] array)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w . j a v a 2 s . com * Convert a byte array to hexadecimal representation * * @param array * Array to convert * @return Hexadecimal representation */ public static String toHexadecimal(final byte[] array) { final int length = array.length; final char[] chars = new char[length * 2]; int indexWrite = 0; int b; for (int indexRead = 0; indexRead < length; indexRead++) { b = array[indexRead] & 0xFF; chars[indexWrite++] = Integer.toHexString((b >> 4) & 0xF).charAt(0); chars[indexWrite++] = Integer.toHexString(b & 0xF).charAt(0); } return new String(chars); } }