Here you can find the source of toLong(byte[] bytes, int offset)
Parameter | Description |
---|---|
bytes | the bytes |
offset | the offset |
public static long toLong(byte[] bytes, int offset)
//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; } }