Here you can find the source of toHexString(byte[] byteArray)
Parameter | Description |
---|---|
byteArray | A byte array to convert to a hex string. |
public static String toHexString(byte[] byteArray)
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w . j a v a2 s.com*/ * Hex characters for use producing human readable strings. */ public static final String hexChars = "0123456789ABCDEF"; /** * Converts a byte array to hex string without leading 0x. * * @param byteArray A byte array to convert to a hex string. * @return A string representing the hex representation of the input. */ public static String toHexString(byte[] byteArray) { if (byteArray == null) { return null; } final StringBuilder sb = new StringBuilder(2 + 2 * byteArray.length); for (final byte b : byteArray) { sb.append(hexChars.charAt((b & 0xF0) >> 4)).append(hexChars.charAt((b & 0x0F))); } return sb.toString(); } }