Here you can find the source of toHexString(byte[] bytes)
toHexString.
Parameter | Description |
---|---|
bytes | an array of byte. |
public static final String toHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { /**/* w ww.j a va 2 s. c o m*/ * <p>toHexString.</p> * * @param bytes an array of byte. * @return a {@link String} object. */ public static final String toHexString(byte[] bytes) { StringBuilder ret = new StringBuilder(64); for (byte each : bytes) { String hexStr = Integer.toHexString(each >= 0 ? each : (256 + each)); if (hexStr.length() == 1) { ret.append("0"); } ret.append(hexStr); } return ret.toString(); } }