Here you can find the source of toHexString(final byte hex)
public static String toHexString(final byte hex)
//package com.java2s; public class Main { public static String toHexString(final byte hex) { return "0x" + Integer.toHexString(hex & 0x000000FF); }//from w w w . j a v a 2s .com public static String toHexString(final short hex) { return "0x" + Integer.toHexString(hex & 0x0000FFFF); } public static String toHexString(final int hex) { return "0x" + Integer.toHexString(hex); } public static String toHexString(final long hex) { return "0x" + Long.toHexString(hex); } }