/** Convert bytes into hexadecimal string * * @param bytes an array of bytes to convert to hexadecimal * * @return bytes as hexadecimal string, e.g. 00 FA 12 ... */ public static final String toHexString( byte[] bytes ) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { short b = byteToShort(bytes[i]); String hex = Integer.toString(b, 0x10); if (b < 0x10) { buf.append('0'); } buf.append(hex); if (i < bytes.length - 1) { buf.append(' '); } } return buf.toString(); }
/** Convert bytes into hexadecimal string * * @param bytes an array of bytes to convert to hexadecimal * * @return bytes as hexadecimal string, e.g. 00 FA 12 ... */ public static final String toHexString( byte[] bytes ) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { short b = byteToShort(bytes[i]); String hex = Integer.toString(b, 0x10); if (b < 0x10) { buf.append('0'); } buf.append(hex); if (i < bytes.length - 1) { buf.append(' '); } } return buf.toString(); }
/** Convert bytes into hexadecimal string * * @param bytes an array of bytes to convert to hexadecimal * * @return bytes as hexadecimal string, e.g. 00 FA 12 ... */ public static final String toHexString( byte[] bytes ) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { short b = byteToShort(bytes[i]); String hex = Integer.toString(b, 0x10); if (b < 0x10) { buf.append('0'); } buf.append(hex); if (i < bytes.length - 1) { buf.append(' '); } } return buf.toString(); }