code: public static long toLong(byte[] bytes, int offset, final int length) {
      if (length != SIZEOF_LONG || offset + length > bytes.length) {
        throw explainWrongLengthOrOffset(bytes, offset, length, SIZEOF_LONG);
      }
      long l = 0;
      for (int i = offset; i < offset + length; i++) {
        l <<= 8;
        l ^= bytes[i] & 0xFF;
      }
      return l;
    }
docs: Converts a byte array to a long value.
  
  @param bytes array of bytes
  @param offset offset into array
  @param length length of data (must be {@link #SIZEOF_LONG})
  @return the long value
  @throws IllegalArgumentException if length is not {@link #SIZEOF_LONG} or
  if there's not enough room in the array at the offset indicated.