Here you can find the source of bytesToHex(byte[] b)
Parameter | Description |
---|---|
b | byte array to convert |
public static String bytesToHex(byte[] b)
//package com.java2s; // it under the terms of the GNU Lesser General Public License as published public class Main { /**/* w w w . j ava2s.c om*/ * Converts a byte array to a representative string of hex digits. * @param b byte array to convert * @return representative string of hex digits */ public static String bytesToHex(byte[] b) { String s = ""; for (int i = 0; i < b.length; i++) { if (i > 0 && i % 4 == 0) { s += " "; } s += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1); } return s; } }