public static final byte[] getAsBytes(long value, byte[] bytes, int startIdx) { bytes[startIdx] = (byte) ((value >> 56)); bytes[startIdx + 1] = (byte) ((value >> 48)); bytes[startIdx + 2] = (byte) ((value >> 40)); bytes[startIdx + 3] = (byte) ((value >> 32)); bytes[startIdx + 4] = (byte) ((value >> 24)); bytes[startIdx + 5] = (byte) ((value >> 16)); bytes[startIdx + 6] = (byte) ((value >> 8)); bytes[startIdx + 7] = (byte) ((value >> 0)); return bytes; } public static final long getLong(byte[] bytes, int startIdx) { return (((long) bytes[startIdx]) << 56) + ((((long) bytes[startIdx + 1]) & 0x00000000000000FF) << 48) + ((((long) bytes[startIdx + 2]) & 0x00000000000000FF) << 40) + ((((long) bytes[startIdx + 3]) & 0x00000000000000FF) << 32) + ((((long) bytes[startIdx + 4]) & 0x00000000000000FF) << 24) + ((((long) bytes[startIdx + 5]) & 0x00000000000000FF) << 16) + ((((long) bytes[startIdx + 6]) & 0x00000000000000FF) << 8) + (((long) bytes[startIdx + 7]) & 0x00000000000000FF); }