Java Long Number Create toLong(byte[] bytes, int offset)

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

Description

To long.

License

Open Source License

Parameter

Parameter Description
bytes the bytes
offset the offset

Return

the long

Declaration

public static long toLong(byte[] bytes, int offset) 

Method Source Code

//package com.java2s;
/*******************************************************************************
* Copyright (c) 2013 Vladimir Rodionov. All Rights Reserved
*
* This code is released under the GNU Affero General Public License.
*
* See: http://www.fsf.org/licensing/licenses/agpl-3.0.html
*
* VLADIMIR RODIONOV MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
* OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
* NON-INFRINGEMENT. Vladimir Rodionov SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED
* BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR
* ITS DERIVATIVES.//from   w  w w .ja  va  2  s.c om
*
* Author: Vladimir Rodionov
*
*******************************************************************************/

public class Main {
    /**
     * To long.
     *
     * @param bytes the bytes
     * @param offset the offset
     * @return the long
     */
    public static long toLong(byte[] bytes, int offset) {
        long l = 0;
        for (int i = offset; i < offset + 8; i++) {
            l <<= 8;
            l ^= bytes[i] & 0xFF;
        }
        return l;
    }
}

Related

  1. toLong(byte[] bytes, boolean bigEndian)
  2. toLong(byte[] bytes, int index)
  3. toLong(byte[] bytes, int index)
  4. toLong(byte[] bytes, int offset)
  5. ToLong(byte[] bytes, int offset)
  6. toLong(byte[] bytes, int offset)
  7. toLong(byte[] data)
  8. toLong(byte[] data)
  9. toLong(byte[] data)