public static final String padHexString ( int num , int width ) { final String zeroPad = "0000000000000000" ; String str = Integer . toHexString ( num ) ; final int length = str . length ( ) ; if ( length >= width ) return str ; StringBuilder buffer = new StringBuilder ( zeroPad . substring ( 0 , width ) ) ; buffer . replace ( width - length , width , str ) ; return buffer . toString ( ) ; }
Returns the provided integer padded to the specified number of characters with zeros .