Here you can find the source of bytesToString(final byte[] bytes)
Parameter | Description |
---|---|
bytes | to create hex string with |
public static String bytesToString(final byte[] bytes)
//package com.java2s; /* See LICENSE for licensing and NOTICE for copyright. */ public class Main { /**/*from w w w . j a v a 2s. co m*/ * Returns a string representation of the supplied byte array in hex format. * * @param bytes to create hex string with * * @return hex string */ public static String bytesToString(final byte[] bytes) { final StringBuilder sb = new StringBuilder(bytes.length * 2); // CheckStyle:MagicNumber OFF for (byte b : bytes) { final int v = b & 0xff; if (v < 16) { sb.append('0'); } sb.append(Integer.toHexString(v)).append(":"); } // CheckStyle:MagicNumber ON return sb.toString().toUpperCase(); } }