将字节数组转换为十六进制格式。
/* * WireSpider * * Copyright (c) 2015 kazyx * * This software is released under the MIT License. * http://opensource.org/licenses/mit-license.php *//**时 代 J a v a - nowjava.com**/ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { byte[] bytes = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; System.out.println(toHex(bytes)); } private static final char[] HEX_SOURCE = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Convert byte array to HEX format. * * @param bytes Source byte array * @return HEX format. */ public static String toHex(byte[] bytes) { StringBuilder sb = new StringBuilder(); sb.append("0x"); for (