private static String hexFormat ( int trgt ) { String s = Integer . toHexString ( trgt ) ; int sz = s . length ( ) ; if ( sz == 8 ) { return s ; } int fill = 8 - sz ; StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < fill ; ++ i ) { // add leading zeros buf . append ( ' ' ) ; } buf . append ( s ) ; return buf . toString ( ) ; }
Returns an 8 character hexidecimal representation of trgt . If the result is not equal to eight characters leading zeros are prefixed .