Java Long Number Create toLong(byte[] bytes)

Here you can find the source of toLong(byte[] bytes)

Description

to Long

License

Open Source License

Declaration

public static long toLong(byte[] bytes) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Shuichi Miura.// w w  w. ja v  a  2s .c  o  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Shuichi Miura - initial API and implementation
 ******************************************************************************/

public class Main {
    public static long toLong(byte[] bytes) {

        return ((long) bytes[7] & 255L) + (((long) bytes[6] & 255L) << 8) + (((long) bytes[5] & 255L) << 16)
                + (((long) bytes[4] & 255L) << 24) + (((long) bytes[3] & 255L) << 32)
                + (((long) bytes[2] & 255L) << 40) + (((long) bytes[1] & 255L) << 48)
                + (((long) bytes[0] & 255L) << 56);
    }
}

Related

  1. toLong(byte[] byteArray)
  2. toLong(byte[] bytes)
  3. toLong(byte[] bytes)
  4. toLong(byte[] bytes)
  5. toLong(byte[] bytes)
  6. toLong(byte[] bytes)
  7. toLong(byte[] bytes)
  8. toLong(byte[] bytes)
  9. toLong(byte[] bytes)