Here you can find the source of asHex(int i)
public static String asHex(int i)
//package com.java2s; //License from project: Open Source License public class Main { private static final String zeroChars = "00000000"; public static String asHex(int i, boolean hexIsDefault, boolean signed, boolean padZero) { String sign = ""; if (signed && i < 0) { sign = "-"; i = -i;/*from w w w .j a va2 s. com*/ } String s = Integer.toHexString(i); return sign + (hexIsDefault ? (padZero ? zeroChars.substring(s.length()) : "") : (i < 10 ? "" : "0x")) + s; } public static String asHex(int i, boolean hexIsDefault) { return asHex(i, hexIsDefault, false, true); } public static String asHex(int i) { return asHex(i, true, false, true); } }