Here you can find the source of toHexString(byte[] data)
Parameter | Description |
---|---|
data | a parameter |
public static String toHexString(byte[] data)
//package com.java2s; public class Main { /**/*from www . j av a 2 s.com*/ * Produces a string with each byte in two-digit hex * and no spaces between each byte. * @param data * @return */ public static String toHexString(byte[] data) { if (data == null) { return null; } // TODO: write more efficient implementation String s = ""; for (int i = 0; i < data.length; i++) { byte b = data[i]; if ((b >= 0) && (b < 16)) { s = s + "0"; } s = s + Integer.toHexString(b & 0xff); } return s; } }