Here you can find the source of toHexString(byte[] byteArray)
Parameter | Description |
---|---|
byteArray | the byte array. |
public static String toHexString(byte[] byteArray)
//package com.java2s; public class Main { /**// w w w . ja v a2 s . co m * Takes a byte array and returns it HEX representation. * * @param byteArray * the byte array. * @return the HEX representation. */ public static String toHexString(byte[] byteArray) { if (byteArray != null && byteArray.length != 0) { StringBuilder builder = new StringBuilder(byteArray.length * 3); for (int i = 0; i < byteArray.length; i++) { builder.append(String.format("%02X", 0xFF & byteArray[i])); if (i < byteArray.length - 1) { builder.append(' '); } } return builder.toString(); } else { return "--"; } } }