Here you can find the source of toHexString(int[] data)
public static String toHexString(int[] data)
//package com.java2s; public class Main { public static String toHexString(int[] data) { if (data == null) return "null"; StringBuilder stringBuilder = new StringBuilder(data.length * 5); stringBuilder.append('['); for (int i = 0; i < data.length; i++) { stringBuilder.append(String.format("0x%02X", data[i])); if (i + 1 < data.length) stringBuilder.append(", "); }/*from w w w. j a va 2 s . c o m*/ return stringBuilder.append(']').toString(); } public static String toHexString(byte[] data) { if (data == null) return "null"; StringBuilder stringBuilder = new StringBuilder(data.length * 5); stringBuilder.append('['); for (int i = 0; i < data.length; i++) { stringBuilder.append(String.format("0x%02X", data[i])); if (i + 1 < data.length) stringBuilder.append(", "); } return stringBuilder.append(']').toString(); } }