Here you can find the source of byteArrayToHexString(final byte[] array)
Parameter | Description |
---|---|
array | the array |
public static String byteArrayToHexString(final byte[] array)
//package com.java2s; public class Main { /** The Constant HEXES. */ private static final String HEXES = "0123456789ABCDEF"; /**/*www . ja v a 2s . com*/ * Gets a pretty representation of a Byte Array as a HEX String. * * Sample output: [01, 30, FF, AA] * * @param array the array * @return the string */ public static String byteArrayToHexString(final byte[] array) { final StringBuffer sb = new StringBuffer(); boolean firstEntry = true; sb.append('['); for (final byte b : array) { if (!firstEntry) { sb.append(", "); } sb.append(HEXES.charAt((b & 0xF0) >> 4)); sb.append(HEXES.charAt((b & 0x0F))); firstEntry = false; } sb.append(']'); return sb.toString(); } }