Here you can find the source of bytesToLong(byte[] array, int offset)
long
from byte
s that was encoded with #longToBytes(long,byte[],int) .
Parameter | Description |
---|---|
array | the array of bytes |
offset | the offset in <code>array</code> to start reading from |
long
public static long bytesToLong(byte[] array, int offset)
//package com.java2s; /****************************************************************************** * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w ww . j a v a2 s . c o m*/ * Aggregate Knowledge - implementation ******************************************************************************/ public class Main { /** * Reconstructs a <code>long</code> from <code>byte</code>s that was encoded * with {@link #longToBytes(long, byte[], int)}. * * @param array the array of bytes * @param offset the offset in <code>array</code> to start reading from * @return the encoded <code>long</code> */ public static long bytesToLong(byte[] array, int offset) { long value = (long) array[offset + 0] & 0x00000000000000ff; value = (value << 8) | (array[offset + 1] & 0x00000000000000ff); value = (value << 8) | (array[offset + 2] & 0x00000000000000ff); value = (value << 8) | (array[offset + 3] & 0x00000000000000ff); value = (value << 8) | (array[offset + 4] & 0x00000000000000ff); value = (value << 8) | (array[offset + 5] & 0x00000000000000ff); value = (value << 8) | (array[offset + 6] & 0x00000000000000ff); value = (value << 8) | (array[offset + 7] & 0x00000000000000ff); return value; } }