Here you can find the source of formatHexInt(final StringBuilder dst, final int p, int w)
private static void formatHexInt(final StringBuilder dst, final int p, int w)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { private static final char[] hexchar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 'a', 'b', 'c', 'd', 'e', 'f' }; private static void formatHexInt(final StringBuilder dst, final int p, int w) { int o = p + 7; while (o >= p && w != 0) { dst.setCharAt(o--, hexchar[w & 0xf]); w >>>= 4;/*from www . j a v a2 s .co m*/ } while (o >= p) { dst.setCharAt(o--, '0'); } } }