Here you can find the source of toHexString(final byte[] arr)
public static String toHexString(final byte[] arr)
//package com.java2s; public class Main { public static String toHexString(final byte[] arr) { final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Integer.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Integer.toHexString(arr[i])); }/* ww w . jav a 2 s . c o m*/ buffer.append(']'); return buffer.toString(); } public static String toHexString(final char[] arr) { final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Integer.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Integer.toHexString(arr[i])); } buffer.append(']'); return buffer.toString(); } public static String toHexString(final short[] arr) { final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Integer.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Integer.toHexString(arr[i])); } buffer.append(']'); return buffer.toString(); } public static String toHexString(final int[] arr) { final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Integer.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Integer.toHexString(arr[i])); } buffer.append(']'); return buffer.toString(); } public static String toHexString(final long[] arr) { final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Long.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Long.toHexString(arr[i])); } buffer.append(']'); return buffer.toString(); } public static String toHexString(final float[] arr) { final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Float.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Float.toHexString(arr[i])); } buffer.append(']'); return buffer.toString(); } public static String toHexString(final double[] arr) { final StringBuilder buffer = new StringBuilder(); buffer.append('['); if (arr.length > 0) buffer.append(Double.toHexString(arr[0])); for (int i = 1; i < arr.length; i++) { buffer.append(' '); buffer.append(Double.toHexString(arr[i])); } buffer.append(']'); return buffer.toString(); } }