Here you can find the source of bytesToLong(final byte[] data, final int offset)
public static long bytesToLong(final byte[] data, final int offset)
//package com.java2s; /*/*from www . ja va 2 s .c o m*/ * Copyright (C) 2010 Indeed Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Undo {@link #longToBytes(long)} and reconstruct the long value. */ public static long bytesToLong(final byte[] data, final int offset) { if (data == null) { return 0x0; } return (long) (0xff & data[offset + 0]) << 56 | (long) (0xff & data[offset + 1]) << 48 | (long) (0xff & data[offset + 2]) << 40 | (long) (0xff & data[offset + 3]) << 32 | (long) (0xff & data[offset + 4]) << 24 | (long) (0xff & data[offset + 5]) << 16 | (long) (0xff & data[offset + 6]) << 8 | (long) (0xff & data[offset + 7]); } }