Here you can find the source of toLong(byte[] input)
Parameter | Description |
---|---|
input | A network byte-ordered representation of a long . |
public static long toLong(byte[] input)
//package com.java2s; //License from project: BSD License public class Main { /**/*from w ww. j a va 2 s .c om*/ * Converts a given byte array to a {@code long}. Bytes are expected in * network byte * * @param input A network byte-ordered representation of a {@code long}. * @return The {@code long} value represented by the input array */ public static long toLong(byte[] input) { assert input.length == 8 : "toLong(): Byte array length must be 8."; long output = 0; output = ((long) (input[0] & 0xff) << 56); output |= ((long) (input[1] & 0xff) << 48); output |= ((long) (input[2] & 0xff) << 40); output |= ((long) (input[3] & 0xff) << 32); output |= ((long) (input[4] & 0xff) << 24); output |= ((long) (input[5] & 0xff) << 16); output |= ((long) (input[6] & 0xff) << 8); output |= (input[7] & 0xff); return output; } }