Here you can find the source of toHexString(byte[] data)
Parameter | Description |
---|---|
data | The data |
public static String toHexString(byte[] data)
//package com.java2s; //License from project: Apache License public class Main { /**//from w w w. ja va 2 s . c o m * Returns the specified data as hex sequence * * @param data * The data * @return a hex string */ public static String toHexString(byte[] data) { final int n = data.length; final StringBuilder hex = new StringBuilder(); for (int i = 0; i < n; i++) { final byte b = data[i]; hex.append(String.format("%02x", b & 0xff)); } return hex.toString(); } }