Here you can find the source of bytesToHexString(byte[] bytes)
Parameter | Description |
---|---|
bytes | a parameter |
public static final String bytesToHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /**//from www.j a v a 2 s. c o m * The fastest method to convert a byte array to hex string. * @param bytes * @return */ public static final String bytesToHexString(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; int v; for (int j = 0; j < bytes.length; j++) { v = bytes[j] & 0xFF; hexChars[j * 2] = HEX_CHARS[v / 16]; hexChars[j * 2 + 1] = HEX_CHARS[v % 16]; } return new String(hexChars); } }