Here you can find the source of toHexString(byte[] b)
Parameter | Description |
---|---|
b | a parameter |
public static String toHexString(byte[] b)
//package com.java2s; public class Main { /**/*w w w.j ava 2s . c o m*/ * translate byte array to Hex String . * * @param b * @return */ public static String toHexString(byte[] b) { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < b.length; ++i) { buffer.append(toHexString(b[i])); } return buffer.toString(); } /** * translate byte to hex String * * @param b * @return */ private static String toHexString(byte b) { char[] buffer = new char[2]; buffer[0] = Character.forDigit((b >>> 4) & 0x0F, 16); buffer[1] = Character.forDigit(b & 0x0F, 16); return new String(buffer); } }