Here you can find the source of bytes2long(byte[] byteArray, int offset)
Parameter | Description |
---|---|
byteArray | byte array |
offset | start index in byte array |
public final static long bytes2long(byte[] byteArray, int offset)
//package com.java2s; /*/*from w w w. j a va 2s.c o m*/ * Helper Class for Catena v3.3 * * Copyright (C) 2016 Axel von dem Bruch * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * See: https://www.gnu.org/licenses/lgpl-2.1.html * You should have received a copy of the GNU General Public License * along with this library. */ public class Main { /** * Convert an array of 8 bytes in a 64 bit long value * in little endian order * * @param byteArray byte array * @param offset start index in byte array * * @return the resulting 64 bit long value */ public final static long bytes2long(byte[] byteArray, int offset) { return (((long) byteArray[offset] & 0xFF) | (((long) byteArray[offset + 1] & 0xFF) << 8) | (((long) byteArray[offset + 2] & 0xFF) << 16) | (((long) byteArray[offset + 3] & 0xFF) << 24) | (((long) byteArray[offset + 4] & 0xFF) << 32) | (((long) byteArray[offset + 5] & 0xFF) << 40) | (((long) byteArray[offset + 6] & 0xFF) << 48) | (((long) byteArray[offset + 7] & 0xFF) << 56)); } }