public static byte [ ] longToBytesNoLeadZeroes ( long val ) { // todo: improve performance by while strip numbers until (long >> 8 == 0) if ( val == 0 ) return EMPTY_BYTE_ARRAY ; byte [ ] data = ByteBuffer . allocate ( 8 ) . putLong ( val ) . array ( ) ; return stripLeadingZeroes ( data ) ; }
Converts a long value into a byte array .