Here you can find the source of bytesToHexString(byte[] array)
Parameter | Description |
---|---|
array | the array of bytes to convert |
public static String bytesToHexString(byte[] array)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "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 w w w.j ava 2s. c o m * Converts the given byte array to a hexadecimal string that can be converted * back by {@link #hexStringToBytes(String)}. * * @param array the array of bytes to convert * @return the hexadecimal string */ public static String bytesToHexString(byte[] array) { StringBuilder sb = new StringBuilder(array.length * 2); for (int i = 0; i < array.length; ++i) { sb.append(HEX_CHARS[(array[i] >>> 4) & 0xF]); sb.append(HEX_CHARS[array[i] & 0xF]); } return sb.toString(); } }