Here you can find the source of toHexString(final byte[] bytes)
Parameter | Description |
---|---|
bytes | an array containing bytes |
public static String toHexString(final byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { private static final String HEXES = "0123456789ABCDEF"; /**//from w w w .j a v a 2 s. co m * Builds a Hex-String from a byte array. * @param bytes an array containing bytes * @return a Hex-String of the contents of the supplied byte array. */ public static String toHexString(final byte[] bytes) { final StringBuilder sb = new StringBuilder(); for (final byte b : bytes) { sb.append(HEXES.charAt((b & 0xF0) >> 4)); sb.append(HEXES.charAt(b & 0x0F)); } return sb.toString(); } }