BitConverter { public static long toInt64(byte[] data, int offset) { return (((long) (data[offset + 7] & 0xff) << 56) | ((long) (data[offset + 6] & 0xff) << 48) | ((long) (data[offset + 5] & 0xff) << 40) | ((long) (data[offset + 4] & 0xff) << 32) | ((long) (data[offset + 3] & 0xff) << 24) | ((long) (data[offset + 2] & 0xff) << 16) | ((long) (data[offset + 1] & 0xff) << 8) | (data[offset] & 0xff)); }  static byte[] getBytes(short v); static byte[] getBytes(int v); static byte[] getBytes(long v); static byte[] getBytes(float v); static byte[] getBytes(double v); static byte[] getBytes(String v); static String toString(byte[] data, int offset); static float toFloat(byte[] data, int offset); static double toDouble(byte[] data, int offset); static short toInt16(byte[] data, int offset); static int toInt32(byte[] data, int offset); static long toInt64(byte[] data, int offset); static byte[] asByteArray(UUID uuid); static UUID toUUID(byte[] byteArray); static UUID toUUID(byte[] byteArray, int offset);  }
@Test public void testToInt64() { assertEquals( 0xABCDEF0123457890L, BitConverter.toInt64(new byte[] { (byte) 0x90, 0x78, 0x45, 0x23, 0x01, (byte) 0xEF, (byte) 0xCD, (byte) 0xAB }, 0)); }