Here you can find the source of toHexString0x(byte[] byteArray)
public static String toHexString0x(byte[] byteArray)
//package com.java2s; //License from project: Apache License public class Main { private static final String hexChars = "0123456789ABCDEF"; public static String toHexString0x(byte[] byteArray) { if (byteArray == null) { return null; }//from w w w . java2 s . c o m return "0x" + toHexString(byteArray); } public static String toHexString(byte[] byteArray) { if (byteArray == null) { return null; } final StringBuilder sb = new StringBuilder(2 + 2 * byteArray.length); for (final byte b : byteArray) { sb.append(hexChars.charAt((b & 0xF0) >> 4)).append(hexChars.charAt((b & 0x0F))); } return sb.toString(); } }