Here you can find the source of formatHexBytes(byte[] raw)
Parameter | Description |
---|---|
raw | a parameter |
public static String formatHexBytes(byte[] raw)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww. j av a 2 s. c o m*/ * Format a raw array of binary bytes as a hexadecimal string. * * @param raw * @return */ public static String formatHexBytes(byte[] raw) { StringBuffer buffer; final char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; int i; int value; buffer = new StringBuffer(raw.length * 2); for (i = 0; i < raw.length; i++) { value = raw[i]; buffer.append(hexDigits[(value >> 4) & 0x0F]); buffer.append(hexDigits[value & 0x0F]); } return buffer.toString(); } }