Here you can find the source of bytesToHexString(byte[] b)
Parameter | Description |
---|---|
b | the vector to convert |
public static String bytesToHexString(byte[] b)
//package com.java2s; public class Main { /**// ww w . j av a 2s . com * Convert a vector of bytes into a regularily formatted string * of hexadecimal values. * @param b the vector to convert * @return the result of the processing */ public static String bytesToHexString(byte[] b) { String space = " "; StringBuilder sb = new StringBuilder(); for (int index = 0; index < b.length; index++) { int tmp = b[index]; tmp &= 0xFF; sb.append("0x"); if (tmp < 16) sb.append(space); sb.append(Integer.toHexString(tmp)); if (index != b.length - 1) sb.append(space); } return sb.toString(); } }